vendredi 13 juillet 2018

Strange output with if-else statement inside of if-else

Hello guys Im quite surprised on how stupid this problem seems but I still can't figure out what Im doing wrong.

I have this code:

if (i.getName().toLowerCase().equals(object)) {
                System.out.println("1");
                if (i.isUsable() && !i.isUsed()) {
                    System.out.println("2");
                    response = "\n " + i.use();
                    break;
                } else {
                    System.out.println("3");
                    response = "\n This item can not be used here or yet or has been used already!";
                }
            } else {
                System.out.println("4");
                response = "\n No item with this name!";
            }

And my output in the console is this:

1
3
4

How can I get 4 if I got 1?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire