+ 3
How do you get the scanner working on java?
Anybody know
2 Answers
+ 2
Well to start, you first need to import the library that contains the scanner for Java:
import java.util.Scanner;
Next, you would need to declare a variable with data type Scanner creating a new instance of the Scanner class, and System.in as a parameter:
Scanner x = new Scanner(System.in);
+ 2
At the beginng you must to import the Java.util.Scanner;.
If you have finished, you can use the Scanner with: Scanner sc = new Scanner(System.in);.
You can scan a nummber with int x = sc.nextInt();
If you want to scan a text, you can do that with: String s = sc.next();
If you are finished to use the scanner you MUST to use the command sc.close();