int menu = scanner.nextInt(); System.out.print("The menu you want" + menu + "Is the number correct? (Y/N):"); String yn = scanner.next();
And then If you enter Y, the menu + "Number" order has been completed." If you enter N, please select the menu again." I'd like to print out.
I tried to write if(yn == y) but I got an error. Can't string be used as a conditional expression like int?
java
Use in the form of yn == y
to compare where the string is stored.
If you want to compare the contents of a string, you must use it in the form of yn.equals(y)
.
© 2024 OneMinuteCode. All rights reserved.