Why we write public static void main(String args[]) in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we write public static void main(String args[]) in java?

13th Jun 2019, 8:49 AM
Nidhi pandey
Nidhi pandey - avatar
3 Answers
+ 2
String denotes the type of the array contents. [] creates an array of this type. args is the identifier to access the content
13th Jun 2019, 8:59 AM
Loeschzwerg
+ 3
Because Java is ugly for beginners. public denotes the function as openly accessible static means that there is only one type of this function, that shall be executed void says, that the main function doesn't return anything String args[] creates a String array of all the command line arguments you give to the function
13th Jun 2019, 8:53 AM
Loeschzwerg
+ 1
But how does the string args[] works?
13th Jun 2019, 8:56 AM
Nidhi pandey
Nidhi pandey - avatar