Here :
for (ArrayList<IntegerPair> l1 : AdjList) {
for (IntegerPair n : l1) {
System.out.println( n + "# ");
}
}
You don't differentiate each printed List.
As a result, you will have a series of output without knowing those associated to a same list.
A more readable print would be :
for (ArrayList<IntegerPair> l1 : AdjList) {
System.out.println("ArrayList with :");
for (IntegerPair n : l1) {
System.out.println( n + "# ");
}
}
You don't specify your output. So I don't suppose toString() is or not overridden. If it is not overridden you should either override it to render the String expected here : System.out.println( n + "# ");, or you should specify the content to render here :
System.out.println( n.getOne() + "," + n.getOther() + "# ");
As a side note, toString() is designed for debugging/logging, not for displaying functional messages as an object could be rendered in a way for a case and in another way for other cases.
IntegerPair@...? If so, read JavaDoc forObject.toString();-)IntegerPairclass? Is it yours?