inheritance - how to use inheritence in ArrayList in java? -


this question has answer here:

i hava class called qgnode extends gnode , class qgraph extends graph. in qgnode constructor when call super constructor argument arraylist<qgnode> error occurs. misunderstand inheritance?

here code:

0 public class questiongraph extends graph{     1 2   public questiongraph(arraylist<qgnode> nodes) { 3      super(nodes);   4  } 5 }  1 public class graph { 2 3 arraylist<gnode> nodes; 4 5  public graph(arraylist<gnode> nodes) { 6      this.nodes = nodes; 7 } 8 } 

error occurs @ line 3 , it's syntax error , ide suggest : create method (java.util.arraylist) in questiongraph

inheritance in generics works bit differently. in java arraylist<qgnode> not subtype of arraylist<gnode>.

generics in java , inheritance

inheritance , generics oracle documentation

how works oracle documentation


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -