Java program to accept string from command line

Write a Java program to accept string through command line and display the received command line argument.


In Jdk:

command to compile: javac programname.java
command to run:        java programname argument_name

Example:

javac CodeRegister.java
java CodeRegister http://www.coderegister.co.in

Output:

The String accepted through command line argument is: "http://www.coderegister.co.in"

Java Implementation:

class CodeRegister
{
 public static void main(String args[])
 {
  System.out.println("The String accepted through Command line argument is: \""+args[0]+"\"");
 }
}