java - why methods return a value (except void()) -
this statement oracledoc can't able understand statement please explain example. " can use interface names return types. in case, object returned must implement specified interface "
here's method return type interface (java.util.list
). since can't instantiate interface, method must return instance (object) of class implements list
interface (java.util.arraylist
in example).
public list foo () { return new arraylist (); }
Comments
Post a Comment