Computer Science, asked by richaroy98, 11 months ago

Write a Program to accept a String as a command line argument and print a Welcome message as given below.

Example1)
C:\> java Sample John
O/P Expected : Welcome John

Answers

Answered by StaceeLichtenstein
10

Following are the program in the java language that is mention below

Explanation:

class Sample // class

{  

public static void main(String args[]) // main  method

{  

System.out.println("Welcome " +args[0]); // print  

}  

}  

To run this program following steps are used

compile:>javac  Sample .java  

run: > java  Sample John

Output:

Welcome John

Following are the description of program

  • Create a class "sample ".
  • Used the args[0] it will take the user input as string type .
  • The system.out.println  method print the string .

Learn More :

  • brainly.in/question/914648
Similar questions