Java: cannot figure why code is not logically correct
whenever I enter y or Y and call the method it should print out OK, but it doesn't it skips all the else if's and executes the last else statement "terminating" any suggestions why? i included the import java.lang.String .....thanks
show the input part of the code...that might be the error. Are you inputing a string or a character? you also might look at a method called toUpperCase or something like that, it converts all characters to uppercase so there will be only 1 check without all the or's ( || ) statments...
will always return false in Java, because a string is a final object in java, so every time you assign a string you are actually making a copy of it in a different object, and the condition is checking if someString is a reference to the same object as the constant string, which can't be true.