0

how to get user input

14th Sep 2016, 3:29 PM
jesus
jesus - avatar
3 Answers
+ 1
Import the Scanner package: import java.util.Scanner; To use it: Scanner sc = new Scanner(System.in); System.out.println(sc.nextLine()); You can also use sc.nextInt(), sc.nextDouble(), etc. to scan a number rather than a string.
14th Sep 2016, 3:55 PM
Zen
Zen - avatar
0
Use scanner(Maybe U can try to use Google)
14th Sep 2016, 7:01 PM
749856832
0
There are many methods to get user input : 1. Using scanner class (as explained by Zen) 2. Using bufferedreader : import java.io.*; class demo { public static void main(String args[]) throws IOException // create bufferedreader object : Bufferedreader ob = new Bufferedreader( new InputStreamReader( System.in)); int a = Integer.parseInt(ob.readLine()); 3. using parameter window : Note : this method runs only in BlueJ class demo2 { void main (int n) Hope u find this useful !!
18th Sep 2016, 7:50 AM
Andy
Andy - avatar