[Solved] Command Line Argument Print String with Java

Write a program to accept a string as command line argument and print the same.

Sample Input (Command Line Argument) 1:
Programming

Sample Output 1:
Programming – Command Line Arguments

Sample Input (Command Line Argument) 2:
Arguments

Sample Output 2:
Arguments – Command Line Arguments

Solution

class Main
{
    public static void main(String args[])
    {
     System.out.println(args[0]+" - Command Line Arguments");
     
}
}

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

πŸ“Œ Nodejs and Android 😎
πŸ“Œ Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *