Mahtab Alam wrote:public class Hose<E extends Hose>
public E get(E e,Hose<E>e2)
return e.getE(); //compiler says found Hose
I know for compiler get() methods return type can only be E nothing else
Please explain clearly ,
I guess it's because when get(E e,Hose<E>e2) is called, e must be instantialized as a specific object corresponding to specific class.
If we want to return E, we have to add a cast. (change return e.getE() to return (E) e.getE() )
On the other hand, if e is not involved, it always works. (Change return e.getE() to return getE() )