Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

how do we take user input from keyboard in java as we use in c++ cin?

OpenStudy (liammeron):

It's been quite awhile since I have used Java, but I recall that you need to import java.util.Scanner and create a new scanner object. Being rather rusty, here is an answer I found on stackoverflow: http://stackoverflow.com/questions/5287538/how-to-get-basic-user-input-for-java

OpenStudy (anonymous):

yes, you could use java.util.Scanner as suggested by Liam or Console class as: Console console = System.console(); String input = console.readLine("Enter input:");

OpenStudy (anonymous):

``` import java.util.Scanner Scanner keyboard = new Scanner(System.in) int data; System.out.println("Enter a number to read in"\n); data = keyboard.nextInt(); ``` Something along those lines

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!