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


Please Help Members By Posting Answers For Below Questions

How to find the index of the largest number in an arraylist java?

528


What is java used for?

564


How do you check if two given string are anagrams?

563


Why constructor has no return type?

646


Why we do exception handling in java and how many types of exceptions are there?

557






In a container there are 5 components. I want to display the all the components names, how will you do that one?

616


What is a pattern what is an anti pattern?

518


What are the two environment variables that must be set in order to run any java programs?

539


How to do a true java ping from windows?

624


What is main in java?

521


What is a boolean used for?

596


How do I remove a character from a string in java?

514


What are the data types supported by java? What is autoboxing and unboxing?

556


Which sorting algorithm is in place?

547


What is a nullable field?

585