java.lang.IndexOutOfBoundsException: Source does not fit in dest

Capacity does not equal size. The size parameter that you are passing in simply allocates enough memory for the size. It does not actually define elements. It’s actually kind of a silly requirement of Collections.copy, but it is one nonetheless.

The key part from the Collections.copy JavaDocs:

The destination list must be at least as long as the source list. If it is longer, the remaining elements in the destination list are unaffected.

You should just pass the List to the ArrayList‘s constructor to copy all of the List to avoid the issue altogether.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)