0

Can I use if statement in getting user input. If yes then how?

23rd Feb 2017, 1:50 PM
pritish ghalta
pritish ghalta - avatar
2 Réponses
+ 9
Scanner scnr = new Scanner(System.in); String input = scnr.nextLine(); if (input.equals("I know what you want to do") ) System.out.println ("Good example, solves the problem"); else System.out.println ("An example that doesn't fit the problem");
23rd Feb 2017, 3:52 PM
Tashi N
Tashi N - avatar
+ 1
You could have a check within the statement and have the input in the statement.
23rd Feb 2017, 2:31 PM
NickB
NickB - avatar