我目前包含以下无法编译的代码。else if语句报告';' expected。我不明白为什么在这种情况下不能使用else if?
public class FileConfiguration {
private String checkOs() {
String path = "";
if (System.getProperty("os.name").startsWith("Windows")) {
// includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
path = "C://Users//...";
}
elseif (System.getProperty("os.name").startsWith("Mac")) {
path = "///Users//...";
}
return path;
}
// declare paths for file source and destination
String destinationPath = path;
String sourcePath = path;发布于 2012-02-16 19:48:37
如果在java中不存在,则返回。如果为,则必须使用else:
if (a) {
// code
} else if (b) {
// code
}https://stackoverflow.com/questions/9310660
复制相似问题