javascript
Brief description  about Online courses   join in Online courses
View ajit mahadeo angaj 's Profile

command line arguments need???

Hi everyone,
I am still doubting why we use command line arguments as we can take them from user? I am not clear with that concept.
Can anyone help me to clear that concept?
Asked by ajit mahadeo angaj | Jun 9, 2013 |  Reply now
Replies (2)
View ajit mahadeo angaj 's Profile
Thanks a lot....But I am more interested in why do we need them as we can request user to input that name of file to sort at run-time. So why there is special need of that command-line arguments over user-inputted values?
Jun 15, 2013
View java teacher 's Profile
A Java application can accept any number of arguments from the command line. This allows the user to specify configuration information when the application is launched.

The user enters command-line arguments when invoking the application and specifies them after the name of the class to be run.


For example, suppose a Java application called Sort sorts lines in a file. To sort the data in a file named friends.txt, a user would enter:

java Sort friends.txt

When an application is launched, the runtime system passes the command-line arguments to the application's main method via an array of Strings.

In the above example, the command-line arguments passed to the Sort application in an array that contains a single String: "friends.txt".

Jun 11, 2013