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
public ArrayList getOutEdgesToP(int id) {
if (!edges.containsKey(id)) {
return null;
}
System.out.println(edges.get(id));
ArrayList a = edges.get(id);
System.out.println("Arraylist a: " + a); // if i print using this its
// okay. but i cant get each
// item in this ArrayList like
// below
for (Object item : a) { // the error of classcastexception is here
System.out.println(item);
}
return a;
}
This should work. I don't have a lot of time to search for an explanation.