+ 1

Class in Java

what is the functionality of the following words? "String[ ] args" in the declaration of the class

24th Oct 2020, 3:30 AM
Ariana Rodríguez
Ariana Rodríguez - avatar
1 ответ
+ 3
String[] args in main method means that it can accept an array of string parameter. You would be able to use this when you compile and execute your code from terminal or command line. You can give command line arguments and can later use them in the code. For example if you have a class name Program. To compile: javac Program.java To run: java Program You can also say: java Program Ariana System.out.print(args [0]); The above line inside main method will print your name.
24th Oct 2020, 3:34 AM
Avinesh
Avinesh - avatar