It gives me output
After Modification [30, [40, 50, 60], 20]
As i have added a list after position 1 and calling tostring Method on alList not on alList1. How the data of alList1 also getting properly.
I know the toString() is overridden but just can't believe that it prinitng the values for innerList at position 1 also.
Can any one help me here? What i am not able to think
public String toString()
Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets (""). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).
Which means that it prints all the elements as they are ordered in your list. When it comes to second element, toString() is invoked on list which returns what's stated above, etc.