Copy Elements from one ArrayList to Another ArrayList
Here is the Program to copy the values from one ArrayList to another ArrayList.
This is the procedure to copying the objects from one list to another.
For Java References:
package collect; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; public class ListClas { public static void main(String[] args) { Listl1=new ArrayList (); l1.add("hi"); l1.add("brother"); ArrayList al=new ArrayList (); al.add("hello"); al.add("guru"); Collections.copy(al,l1); Iterator i= al.iterator(); while(i.hasNext()){ i.hasNext(); System.out.print(" "+i.next()); //System.out.println(al); } } }
This is the procedure to copying the objects from one list to another.
For Java References: