Java 编译器说有一个无法访问的语句,我做错了什么?
执行不会超过Java 编译器说有一个无法访问的语句,我做错了什么?,java,Java,执行不会超过继续。因此,在该块中,后面的所有内容都是不可访问的 可能您想在继续后关闭} 执行不会超过继续。因此,在该块中,后面的所有内容都是不可访问的 可能您想在继续之后关闭}?旁注:OP不需要Java中的^和$matches()隐式检查整个单词。旁注:OP在Java中不需要^和$matches()隐式检查整个单词。 import java.io.File; import java.io.IOException; import java.util.Scanner; class airpor
继续。因此,在该块中,后面的所有内容都是不可访问的
可能您想在继续后关闭}
执行不会超过继续。因此,在该块中,后面的所有内容都是不可访问的
可能您想在继续之后关闭}
?旁注:OP不需要Java中的^和$
matches()
隐式检查整个单词。旁注:OP在Java中不需要^和$
matches()
隐式检查整个单词。
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