Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to clone Collections

Java: How to clone Collections

import java.util.ArrayList;
import java.util.Iterator;
public class CloneCollection
  public static void main(String[] args)
    ArrayList list_tab = new ArrayList();
    for (int i = 0; i < 10; i++)
    System.out.println("v: " + list_tab);
    // clone the ArrayList
    ArrayList list_tab2 = (ArrayList) list_tab.clone();
    // use cloned arrayList
    int x=0;
    for (Iterator e = list_tab2.iterator(); e.hasNext();)
    System.out.println("v: " + list_tab2);

Users who found this page were searching for:

  • clone Collection java
  • java cloning collections

No comments yet.

Leave a Comment