Command Line Arguments in Java


Pre-requisite:

1.Java installed.

Sample code to demonstrate the command line argument in Java.

File:carg.java

class carg
{
public static void main(String ar[])
{
System.out.println(”The Argument you have entered is ” +ar[0]);
}
}

Sample Output:

while running a Java file after the Successful Completion on compiling.

#java carg nice

The Argument you have entered is nice

Feel free to share your comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s