我正在尝试使用 Collections.sort 方法和 java.util.List 创建一个按字母顺序排列列表的程序,错误是:发现 1 个错误和 15 个警告:
Error: java.util.List is abstract; cannot be instantiated
--------------
** Warnings **
--------------
Warning: unchecked call to add(E) as a member of the raw type java.util.List
Warning: unchecked method invocation: method sort in class java.util.Collections is applied to given types
required: java.util.List<T>
found: java.util.List
我的代码:
public static void preset(){
List words= new List();
words.add("apple");
words.add("country");
words.add("couch");
words.add("shoe");
words.add("school");
words.add("computer");
words.add("yesterday");
words.add("wowza");
words.add("happy");
words.add("tomorrow");
words.add("today");
words.add("research");
words.add("project");
Collections.sort(words);
} //end of method preset