why we write public static void main (String args[])
in core java plz explain briefly??????????????????
Answer Posted / nilay
because in JAVA everything is within class and should be
called with classname(static methods) or with instance of
that class. but main is the first method to be called when
no instances are in memory so that is why it is static and
is called like <classname>.main() by System class. and it
must be public because it is called from outside enviornent
of current class file. String[] is for the command line
arguments that you pass when you run your java program
by "java .classfile arg1 arg2" so all arguments are
received here and for multiple arguments it is an array of
strings. it does not return anything so it's return type is
void.
| Is This Answer Correct ? | 17 Yes | 0 No |
Post New Answer View All Answers
What is the difference between member variables initialization and assignment in a constructor?
What is encapsulation in java?
Is it possible for yielded thread to get chance for its execution again ?
Can we access instance variables within static methods ?
How to convert string to byte array and vice versa?
How to solve the problem of generating the unique hash keys with hash function?
What is the symbol for space?
What is api data?
what is synchronization? : Java thread
What's the purpose of using break in each case of switch statement?
What is java autoboxing?
What is a vector in java?
Why is java so important?
How java uses the string and stringbuffer classes?
What does I ++ mean?