How do you what point in your java code must you add a main method() ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you what point in your java code must you add a main method() ?

26th May 2019, 1:44 PM
Iredafe Owolabi
Iredafe Owolabi - avatar
2 Answers
+ 2
No matter where you place the main method, it will always run
26th May 2019, 2:04 PM
Airree
Airree - avatar
+ 1
like other methods, inside class, but not in inner nested class. If you run code on real java environment eg on laptop with installed java JDK, if your code file has name Example.java, method main() must be in class Example
26th May 2019, 4:39 PM
zemiak