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
What is the difference between public, private, protected, and friend access?
What's the base class in java from which all classes are derived?
What is the difference between compare and compareto in java?
What are loops in java? What are three types of loops?
what state does a thread enter when it terminates its processing? : Java thread
Does set allows null in java?
Is a class an object?
How many types of array are there?
When do I need to use reflection feature in java?
What is thread pool? How can we create thread pool in java?
Is stringwriter thread safe?
Can java object be locked down for exclusive use by a given thread?
Write a java program to generate fibonacci series ?
Which is better stringbuilder or stringbuffer?
What is a numeric digit?