java – Print ArrayList

java – Print ArrayList

list.toString() is good enough.

The interface List does not define a contract for toString(), but the AbstractCollection base class provides a useful implementation that ArrayList inherits.

Add toString() method to your address class then do

System.out.println(Arrays.toString(houseAddress));

java – Print ArrayList

From what I understand you are trying to print an ArrayList of arrays and one way to display that would be

System.out.println(Arrays.deepToString(list.toArray()));

Leave a Reply

Your email address will not be published.