A Simple program in JAVA to pass arguments to the program from the command line.

Abhisek
Posted by Abhisek under Others category on | Views : 1874
class Command
{
public static void main(String args[])
{
int i;
for(i=0;i<args.length;i++)
System.out.println(args[i]);
}
}


First compile the program.
Then run the program by passing a string. It will display the string you passed as the output

Ex- java Command I am Abhisek

Here in the above example "I am Abhisek" is the string passed at the command line. So the output will be I am Abhisek .

Comments or Responses

Login to post response