Write a Program to Read User Input and Display Using in Java Programming.

Basically to Read User input there Library in Java Programming called Scanner using (“import java.util.Scanner;”) its Used in yours program.

Example :
System.out.println(“Enter Your String: “);
String text = userinput.nextLine();

Program :

import java.util.Scanner;
public class UserInput{
	public static void main(String args[]) {
		Scanner userinput = new Scanner(System.in);
		System.out.println("Enter Your Name: ");
		String name = userinput.nextLine();
		System.out.println("Your Name Is: " + name);
		userinput.close();
	}
}

Output:

UserInput

(Visited 87 times, 1 visits today)
Share with Friends :
Written by: