I know this has been asked a lot in stackoverflow but I could not find answers that work to my problem.
In the following code below, I cant print out each item in
the error lies here
public void addEdgeForIndexing(int from, int to, int T) throws IllegalArgumentException, IllegalAccessException {
Edge e = new Edge(from,to,T);
nodeIDs.add(e.from);
nodeIDs.add(e.to);
ArrayList tmp = null;
if (edges.containsKey(e.from))
tmp = (ArrayList) edges.get(e.from);
else {
tmp = new ArrayList();
edges.put(e.from,tmp);
}
tmp.add(e);//adding an edge to tmp
later in the code you get the ArrayList out of the Map as ArrayList but it an ArrayList containing Edge try to change
tmp = new ArrayList();
to
tmp = new ArrayList();
you should get a compilation error when adding an Edge to it