我在目标规划的一个新手,所以原谅我,如果这个问题是愚蠢的。
我正在开发一个小到做程序作为练习。但是,当我尝试加载现有的txt文件及任务存储文件夹,IDE告诉我Exception in thread "main" java.lang.NullPointerException
。我读了这个网站描述这种错误流行的一个,我有点明白为什么会发生,但我只是coudn't发现问题。
行ListProcess 17-26:
public ListItem[] loadList() throws FileNotFoundException {
ListItem[] listitem = new ListItem[200];
int listCount=0;
for (String txts : loadTxtsList()) {
File file = new File(txts);
Scanner scanner = new Scanner("List/"+file);
listitem[listCount].isFolder = false;
listitem[listCount].name = txts.replace(".txt", "");
listitem[listCount].description = scanner.nextLine();
int i = scanner.nextInt();
是的,我使用了一个名为列表项类来存储这些任务。
列表项类:
public class ListItem {
boolean isFolder=false;
String name;
String description;
String[] tags = new String[10];
Status status;
}
下面一行:
ListItem[] listitem = new ListItem[200];
创建一个数组,其项目全部null
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句