Parameter of main method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Parameter of main method

why the parameter of main method is an argument of strings and not anything else?

2nd Jan 2018, 2:32 PM
Shalini Jha
Shalini Jha - avatar
4 Answers
+ 18
then its ok ☺ //try making codes also on concepts u learn (can keep them private) , u will learn more faster
2nd Jan 2018, 2:57 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
Because when you run a Java program from the command-line, the command you use looks like this: java nameoffilehere arg0 arg1 arg2... The arg0, arg1, and arg2 are the 0, 1, and 2 indices of the String[] args in the main method. You can use them in your program. Also, args is just a convention, it doesn't have to be named args to function.
2nd Jan 2018, 2:46 PM
LunarCoffee
LunarCoffee - avatar
+ 2
no no.... it's nothing of that sort.... I am just trying to clear the doubts.... as soon as they pop up in my mind..... so that to learn and understand things rather to cram them up
2nd Jan 2018, 2:56 PM
Shalini Jha
Shalini Jha - avatar
+ 2
Hope it's not bothering you :)@Gaurav
2nd Jan 2018, 2:57 PM
Shalini Jha
Shalini Jha - avatar