How would i finish this code Make a copy of an ArrayList wit
How would i finish this code?
Make a copy of an ArrayList with an explicit loop. Complete the following code. Complete the following file: Array Lis tCopy. java import java.util.ArrayList; import java.util.Scanner; public class ArrayListCopy public static void main(String[] args) {Arraylist words = new ArrayList(); Scanner in = new Scanner(System.in); while (in.hasNextO) words.add(in.next()); ArrayList copyOfWords = new ArrayList();//Use a for loop to copy the contents of words ... words.remove(0);//Shouldn\'t affect the copy System.out.println(words); System.out.println(copyOfWords);Solution
ArrayList<String> copyOfWords=new ArrayList<String>();
for(String s:words)
{
copyOfWords.add(s);
}
