Reading Input from Console in Java


Scanner is a simple text scanner which can parse primitive types and strings using regular expressions.

Source Code

Scanner scanner = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = scanner.nextInt();
System.out.println("You are " + age + " years old.");
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments