In Java why we write public static void main(String args[])
why not main()?
Answer Posted / ankur
in java we write public static void main(String args[])
instead of just main because:....
public.....The main method must be public because it is
call from outside the class. It is called by jvm.
static....The main method must be static because without
creating an instace jvm can call it. If the main method is
non static then it is must to create an instance of the
class.
void....Main method doesn't return anything therefore it is
void also.
(String args[])....It is used for receiving any arbitirary
number of arguments and save it in the array.
| Is This Answer Correct ? | 429 Yes | 20 No |
Post New Answer View All Answers
Is java an open source?
What is the difference between a method and a procedure?
Why is singleton class used?
Can a hashset contain duplicates java?
What is an object's lock and which object's have locks in java programming?
How will you invoke any external process in java?
What is singletonlist in java?
Using callable statement how can you pass out parameters, explain with example?
What does it mean that strings are immutable?
Is an integer an object?
When will you define a method as static in Java?
Why does java have different data types for integers and floating-point values?
Why charat is used in java?
What is bitwise complement?
Explain about varargs in java?