学习如何使用JavaArrayLists它不断抛出以下异常:
496cc7/packlist.java:5: error: cannot find symbol List alist = new
ArrayList<>(); ^ symbol: class List location: class packlist 1 error
这对我来说是全新的,所以我不确定到底出了什么问题,任何帮助将不胜感激
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);
}
}
预期结果是 的内容ArrayList,但相反,我收到与第 5 行相关的上述错误
不负相思意
相关分类