Learning how to use Java ArrayLists
it keeps throwing the following exception:
496cc7/packlist.java:5: error: cannot find symbol List alist = new ArrayList<>(); ^ symbol: class List location: class packlist 1 error
This is entirely new to me so im not sure what is actually wrong any help would be greatly appreciated
import java.util.ArrayList;
import java.util.Collections;
class packlist {
public static void main(String args[]) {
List <String> alist = new ArrayList<>();
alist.add("Mark");
alist.add("William");
alist.add("John");
alist.add("Dave");
alist.add("James");
System.out.println("The items of alist are: " + alist);
Collections.reverse(alist);
System.out.println("The reversed items of alist are: " + alist);
}
}
the expected result is the contents of the ArrayList
, but in reverse i am getting the error above relating to line 5