Java Program to Print Simple String entered by user
Java Program to print a string in Java Programming, first you have to ask to the user to enter the string and place that string in any variable say str, and now place this variable str in the bracket of System.out.print()….
SOURCE CODE ::
import java.util.Scanner; public class print_string { public static void main(String args[]) { String str; Scanner scan = new Scanner(System.in); System.out.print("Enter Your Name : "); str = scan.nextLine(); System.out.print("Hello, " + str); } }
OUTPUT ::
Enter Your Name : CodezClub Hello, CodezClub