0
how to get user input
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.
0
Use scanner(Maybe U can try to use Google)
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 !!