How to Read User Input From Console Using Scanner


import java.util.Scanner;
public class Test {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter data :");
String name = s.nextLine(); 
System.out.println(name);
}
}


Output:

Enter data :JavaStuff.in
JavaStuff.in




Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email