java - Generics and inheritance -


given situation:

class school  {     public void print(){} }  class grade extends school{}  class student extends school{} 

what difference between this

public <e extends school> void somemethod(e someobj)  {     //now can pass object extends school      //and have access methods in school     someobj.print();  } 

and this?

public void somemethod(school someobj) {     someobj.print(); } 

the obvious difference 1 generic , other not.

and other know generic 1 can capture actual type of argument. of course doesn't make difference in case. imagine if wanted return type exact type of argument, come picture.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -