I recently found out that there are actually 2 different ArrayList
implementations in Java (better late than never I guess...).
So I was wondering why d
They are two different classes with different behaviours.
The list returned when you called Arrays.asList is a thin wrapper over the array, not a copy. The list returned is fixed size: attempting to call add
will throw an UnsupportedOperationException
exception.
The java.util.ArrayList
on the other hand keeps its own internal copy of the data and is variable sized.