oop - java interface and child class -


i have next question. have interface

public interface myinterface {     blah blah } 

and have child:

public class mychild implemets myinterface {     blah blah } 

what difference between:

mychild child = new mychild(); 

and

myinterface child = new mychild(); 

?

your added code snippet -

mychild child = new mychild();   

and

myinterface child = new mychild();   

in first case child can contain object of mychild class. in second case child (where child myinterface) can contain object of class implements myinterface. here can advantage of polymorphism.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -