I am new to java and am trying to write a method that will print out an ArrayList using an enhanced for loop. Whenever I compile, the fore loop gives me the following errors:
error: cannot find symbol
error: variable list2 is already defined in method printLists(ArrayList,ArrayList) for(String list2: list)
public static void printLists(ArrayList <String> list1, ArrayList <String> list2 )
{
System.out.println("list1.txt contains:");
for(String list1: list)
System.out.println(list1+ " ");
System.out.println("list2.txt contains:");
for(String list2: list)
System.out.println(list2+ " ");
}
Can someone please explain to me what these errors mean?