In Java why we write public static void main(String args[])
why not main()?
Answer Posted / prabhakant prabhakar rasal
We write public because to access main() method outside the
class.
Why static because to invoke main() method before creating
any object, so it simple to compiler that to identify the
main() method.
void, it represents that it does not returns any value.
string args[]
There are two main reasons to write string args[]
1. TO identify the program
2. To get command_line arguments
Is This Answer Correct ? | 27 Yes | 13 No |
Post New Answer View All Answers
How to find the index of the largest number in an arraylist java?
What is java used for?
How do you check if two given string are anagrams?
Why constructor has no return type?
Why we do exception handling in java and how many types of exceptions are there?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
What is a pattern what is an anti pattern?
What are the two environment variables that must be set in order to run any java programs?
How to do a true java ping from windows?
What is main in java?
What is a boolean used for?
How do I remove a character from a string in java?
What are the data types supported by java? What is autoboxing and unboxing?
Which sorting algorithm is in place?
What is a nullable field?