This java main function is correct or not | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

This java main function is correct or not

public class Program { static public void main(String... args) { System.out.println("hello"); } }

10th Apr 2019, 1:40 AM
Narendra Kumar Jha
2 Answers
+ 14
It is correct and should compile as far as I know. I'm too interested though whether there are significant differences between the two or it's just syntactic sugar.
10th Apr 2019, 3:10 AM
1Lory☕
1Lory☕ - avatar
+ 9
I prefer 'public static void main (String [] args)' but this works.
10th Apr 2019, 5:39 AM
Sonic
Sonic - avatar