Showing posts with label About command line argument. Show all posts
Showing posts with label About command line argument. Show all posts

Friday, 30 November 2018

Command line argument in java | About command line argument | What is command line argument in java with example - Online Help

Command line arguments:

command line arguments are parameters that are supplied to the application program at the time of invoking its execution. They must be supplied at the time of its execution following the file name.

In the main() method, the args is confirmed as an array of string known as a string object. Any argument provided in the command line at the time of program execution, are accepted to the array args as its elements. Using index or subscripted entry can access the individual elements of an array. The number of elements in the array args can be getting with the length parameter.

Example:
class add
{
public static void main(String args[])
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c=a+b;
System.out.println("addition is:"+c);
}
}

           I hope you guys understand what is command line argument.if you want to know about java array you guys can know by clicking below link:
https://beingcomputeracy.blogspot.com/2018/11/arrays-in-java.html