Write a Program to Use Scanner Class in Java

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);