Can we need to create special class for main method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can we need to create special class for main method

2nd Oct 2019, 12:21 PM
Keyur Chaudhari
Keyur Chaudhari - avatar
4 Answers
+ 4
No as long as is inside of a class somewere in your program that all that matters.
2nd Oct 2019, 12:38 PM
D_Stark
D_Stark - avatar
+ 2
In Java,the main method has to be inside a class.
2nd Oct 2019, 12:58 PM
Sonic
Sonic - avatar
+ 2
Every Java program must have at least one class and only one main method with String array parameter. Main method must be inside of a class, but you don't need to have special class for it.
11th Oct 2019, 6:20 PM
Александар Жижовић
Александар Жижовић - avatar
+ 1
no, we already mention that... public static void main(string args[]){}in java, in starting of every java program.
2nd Oct 2019, 2:09 PM
SUTRAYE LOKESH
SUTRAYE LOKESH - avatar