How exactly does the "main" method work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

How exactly does the "main" method work?

I understand that in java d main method takes an array of strings as argument but where does this array come from and what does the main method do with it?

17th Apr 2017, 10:35 PM
David Akhihiero
David Akhihiero - avatar
3 Answers
+ 2
all you should know is that the main method runs the program... every method that you create you should added to your main method so you can really see how your program works
17th Apr 2017, 10:42 PM
Christopher Vegerano
Christopher Vegerano - avatar
+ 11
@Claudio what is d program call and what "exactly" does it pass to d main method
18th Apr 2017, 12:07 PM
David Akhihiero
David Akhihiero - avatar
+ 2
public static void main(String[] args) { for(int i = 0; i < args.length; i++) { System.out.println(args[i]); } } args is an array with parameters passed to the function from the program call
17th Apr 2017, 11:09 PM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar