Taking user input in java
1.Java Scanner Class
- Java Scanner class allows the user to take input from the console.
- It belongs to java.util package.
- It is used to read the input of primitive types like int, double, long, short, float, and byte.
- It is the easiest way to read input in Java program.
Syntax :-
Scanner sc = new Scanner(System.in);
- System.in is an argument, It means it is going to read from the standard input stream of the program.
- The java.util package should be import while using Scanner class.
0 Comments