[英]why won't my for loop work to print out value in the text file?
我知道这很简单,但由于某种原因我无法让这个循环工作。 非常感谢帮助
public Instructor()
{
// initialise instance variables
writeMap = new HashMap<String,String>();
notRecognised = new ArrayList<String>();
help = new FileHelper();
notRecognised = help.readAList("missed.txt");
for(String i : notRecognised.length) {
System.out.println(i);
}
}
您增强的 for 循环不正确。 使用列表,而不是长度
for (String i : notRecognised) {
System.out.println(i);
}
可能missed.txt 是空的,因此help.readAList() 函数返回空字符串。
notRecognised = help.readAList("missed.txt");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.