jeudi 18 août 2016

Java - Simple IF condition won't run

I don't know why, it seems to me that Java's IF is different than a BASH's IF or C++'s IF. I might be wrong, at least I hope. This code below is one of the many version of IF I tried, I can not find the error at this moment.

    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");
    }

Aucun commentaire:

Enregistrer un commentaire