i am new to java. Down below i created an ArrayList of LinkedList objects (atleast i thought i did) but when i tried to add something to the Linked-List object the add method function isn't working(in addedge function), it seems like the it returns an "Object type"(Java.lang.Object).
public class DirectedGraph {
private int Nvertices;
private ArrayList LLA, Source;
private final String Tgraph= "Directed";
private DirectedGraph(int nvertices) {
this.Nvertices = nvertices;
LLA = new ArrayList();
Source = new ArrayList();
for (int i=0;i<nvertices;i++){
LLA.add(new LinkedList<String>());
}
}
public void addvertex(String Vtx){
Source.add(Vtx);
}
public void addedge(String Source, String Edge){
LLA.get(Source.indexOf(Source)).add(Edge);//Error cann't resolve add(java.lang.String).
//Also tried LinkedList<String> jk = LLA.get(Source.indexOf(Source)); it returns the type Object.
}
}