我不知道为什么,在我看来,Java的IF与BASH的IF或C ++的IF不同。我可能错了,至少我希望如此。 下面这段代码是我试过的IF的众多版本之一,我现在找不到错误。
String identification = "qwerty1";
String name = identification.substring(0,identification.length()-1); // querty
String version = identification.substring(identification.length()-1,identification.length()); // 1
Database db = new Database();
if (version != "1"){
System.out.println("\nCheck version");
System.out.println(version+"\n");
db.SelectVersion(name, version);
if (db.isSelectVersion()) {
System.out.println("\nUpdating version");
//Database.UpdateVersion(name, version);
}
}
else {
db.Select(identification);
if (db.isSelect()) {
System.out.println("\nThere is something");
//Database.Update(identification, quantity1, quantity2);
} else {
System.out.println("\nThere is nothing");
//Database.Insert(identification, quantity1, quantity2);
}
}
db.Match(name, version);
if (db.isMatch()) {
System.out.println("\nQuantities match\n");
} else {
System.out.println("\nQuantities do not match\n");
}