[英]The compiler is saying that there is an unreachable statement, what am I doing wrong?
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
class airport {
private static final String STDIN_FILENAME = "-";
public static treemap load_database (String database_name) {
treemap tree = new treemap ();
try {
Scanner database = new Scanner (new File (database_name));
for (int linenr = 1; database.hasNextLine(); ++linenr) {
String line = database.nextLine();
if (line.matches ("^\\s*(#.*)?$")) { continue;
//there is a problem with the below line
String[] keyvalue = line.split (":");
if (keyvalue.length != 2) {
misc.warn (database_name, linenr, "invalid line");
continue;
}
tree.put (keyvalue[0], keyvalue[1]);
}
database.close();
}
}
catch (IOException error) {
misc.warn (error.getMessage());
}
return tree;
}
}
if (line.matches ("^\\s*(#.*)?$")) {
continue;
// unreachable code
执行不超过continue
。 因此,该块之后的所有内容均无法访问。
也许您想在continue
之后关闭}
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.