Incompatible types generics Java -


i did code:

import java.util.linkedlist;  public class node<t> { private t data; private linkedlist<t> children; public node(t data) {     this.data = data;     this.children = new linkedlist<t>(); } public t getdata() {     return this.data; } public linkedlist<t> getchildren(){     return this.children; } }   public class graph <t> implements network<t> { private node source; private node target; private arraylist<node> nodes = new arraylist<node>();   public graph(t source,t target) {     this.source = new node(source);     this.target = new node(target);   }   public t source() {     return source.getdata(); }  public t target() {     return target.getdata(); } 

i error on source() , target(): required t found java.lang.object why? type of return of getdata() function it's t(generic type of return)

private node source; private node target; 

these should node<t>. likewise on few of following lines. compiler have given warning. take note of it. (when mix raw types , generics, java language spec requires compiler give up.)


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -