Thursday, July 15, 2021

11. Write a program to print a string entered by user.

 import java.util.Scanner;


public class Main {

      public static void main(String[] args) {

          Scanner sc = new Scanner(System.in);

          System.out.println("Enter a String. ");

          String st = sc.nextLine();

          System.out.println(st);

     }

}


NOTE:

Imported Scanner as input was to be taken from the user. Then asked the user the String . The user can input any kind of String he/she likes. Then at last the String given by the user will be Shown in the Screen.

No comments:

Post a Comment