Write a Program to Use Scanner Class in Java

0
18
digitalample eye
A simple text scanner which can parse primitive types and strings using regular expressions. A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.
The resulting tokens may then be converted into values of different types using different methods.

Program to Use Scanner Class in Java

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here