Can I use if statement in getting user input. If yes then how? | SoloLearn: Learn to code for FREE!

0

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

2/23/2017 1:50:01 PM

pritish ghalta

2 Answers

New Answer

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

+1

You could have a check within the statement and have the input in the statement.