Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsCopyExample4 { @SuppressWarnings("unchecked") public static void main(String[] args) { //Create lists ArrayList source = new ArrayList(); source.add(50); source.add(10); source.add(20); System.out.println("Elements of Source List: " + source); ArrayList dest = new ArrayList(); dest.add("one"); dest.add("two"); dest.add("three"); dest.add("four"); dest.add("five"); System.out.println("Elements of Destination List: " + dest); Collections.copy(dest, source); System.out.println("Elements of Destination List after copying Source List: " + dest); } }
Output