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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -