While launching your application, you can use the command-line arguments to specify the configuration information.Factorial of a number using command-line arguments class Example1 When an application is launched, the run-time system passes the command-line arguments to the application’s main method via an array of Strings. Similarly, args is second, args is the third element and so on. Therefore args is the first index in this String array which is taken from the console. Every Number classes such as Integer, Float, Double and so on have parseXXX methods that convert String into the respective object of their type.Īs we all know that array starts its index with zero. The beauty relies on the parseInt method in the Integer class. Here are a few examples to show how we can use the command-line arguments in a Java program. ![]()
0 Comments
Leave a Reply. |