I am using the following code:
List<Object> dest = new LinkedList<Object>();
Collections.copy(oldList, src);
When I execute the code, I get an exception:
java.lang.IndexOutOfBoundsException: Source does not fit in dest
at java.util.Collections.copy(Collections.java:589)
I know how to fix it, but I do not understand:
When I add items manually, the list will automatically increase capacity. Why can't copy # copy do this?
source
share