我想到了我的学校课程计划的算法,但我认为也有一些基础难点...
这是我的代码和问题:
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
String allWords = System.getProperty("user.home") + "/allwords.txt";
Anagrams an = new Anagrams(allWords);
for(List<String> wlist : an.getSortedByAnQty()) {
//[..............];
}
}
}
public class Anagrams {
List<String> myList = new ArrayList<String>();
public List<String> getSortedByAnQty() {
myList.add("aaa");
return myList;
}
}
我得到了“类型不匹配:无法将元素类型 String 转换为 List”的错误信息,请问如何正确初始化 getSortedByAnQty() 函数呢?