Reading Input with Scanner in Java


Scanner is versatile, allowing you to read various data types from the console.

Source Code

Scanner scanner = new Scanner(System.in);
System.out.print("Enter username: ");
String username = scanner.nextLine();
System.out.println("Username is: " + username);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments