Ads

Friday, 20 October 2017

Command-line Argument in Java

Command-line Argument

→ A command-line argument is the information that directly follows the program's name on the command line when it is executed.

Command-line argument are stored as string in the string array passed to main().

Command-line argument is nothing but run-time agrument.

Thus giving command-line argument is easy.

Example


Class Class1
{
     public staic void main(String args[])
     {
               int a=Integer.parseInt(args[0]);
               System.out.println(a);
      }
}


Post a Comment

Click Here