question POO

question POO - Java - Programmation

Marsh Posté le 15-04-2007 à 18:07:48    

Bonjour,
 
Je voudrais comprendre uun truc dans un ocde que j'ai récupéré, en fait , quand on a une Interface ImyInerface et une classe MyClass qui l'implémente
 

Code :
  1. Interface ImyInterface {
  2. public void myFunc(String i);
  3. }
  4. ------------------ 
  5. MyClass implements ImyInterface{
  6. String toto;   Myclass(){ //constructeur }  
  7. public void myFunc(String i){
  8. ///implémentationnde la méthode
  9. }   
  10. }


 
Ma question est c'est quoi l'intérêt de faire
 
ImyInterface MyInst = new MyClass();
 
au lieu de :
 
MyClass MyInst = new MyClass();
 
Merci


Message édité par root76 le 15-04-2007 à 18:09:47
Reply

Marsh Posté le 15-04-2007 à 18:07:48   

Reply

Marsh Posté le 15-04-2007 à 18:17:18    

http://forum.hardware.fr/hfr/Progr [...] m#t1296679


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed