How to enter the value of String by user and print on console

//How to enter the value of String by user and print on console


import java.util.*;
public class M
{
public static void main(String args[])
{
String str;
System.out.println("Enter the value of string : ");
Scanner sc=new Scanner(System.in);
str=sc.next();
System.out.println("You entered : "+str);
}
}


OUTPUT:
Enter the value of string :
Hello
You entered : Hello

No comments:

Post a Comment