I have trouble with understanding class and main and its roll | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have trouble with understanding class and main and its roll

what's the point of having a main method. And what do you put inside (String[ ] args)

24th Apr 2019, 5:55 PM
Shaurya Sen
Shaurya Sen - avatar
1 Answer
+ 1
Main method is always invoked first. Basically it is where every java program starts from. Starting from JDK 6 having main method is obligatory. String [] args means that it accepts command line arguments (can be passed when you start the program(e.g.,from a terminal)) in an array of type String with the name "args". You can check it's content printing it to the console just like you would do with any other array.
24th Apr 2019, 6:22 PM
{ 𝄋 ℒ 𝄋 }
{ 𝄋 ℒ 𝄋 } - avatar