| Author |
Collections.copy method for lists ? how it works
|
Tanu Gulati
Ranch Hand
Joined: Oct 06, 2008
Posts: 113
|
|
I have a code below where i tried to copy an arrayList to listusing Collections.copy method. I am getting IndexOutofBoundsException since the size of destination list is not equal to the source list. my question.. is there any Java API help through which i can copy an entire list of any size to a new list(the destination list can be of any size and may be empty).
|
thanks
Tanu Gulati
|
 |
rakesh sugirtharaj
Ranch Hand
Joined: Dec 16, 2007
Posts: 151
|
|
|
I think this would work
|
Cheers!
RSR
|
 |
Tanu Gulati
Ranch Hand
Joined: Oct 06, 2008
Posts: 113
|
|
|
hey rakesh ..thanks it works ..thanks a lot
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Even simpler: List list=new ArrayList(arrayList);
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: Collections.copy method for lists ? how it works
|
|
|