In main mehod there is a one paramenter is given as string *** public static void main(String args) *** string args is given to pass comandline argument but if we don't pass any argument then it runs without any error but as a function or method rule if we define a function or method having an argument then must be passed while calling that method but if we don't pass any commandline argument then how it works....?
Since you are not passing in any parameters from the comand line, the args array will have a length of zero. Note that you are not specifically calling this method. The method gets executed by the JVM automatically.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Joined: Sep 09, 2001
if this is activated by JVM then it is OK otherwise according rule it is illegal to call a function without specifying a parameter which has already been defined while function is defined, Am I right ? However Very thanks for your reply, thanks again ------------------ Harjeet Singh Dadwal
If you invoke your program with parameters, the JVM constructs a String array of the parameters, and sends it to main.
If you invoke the program with no parameters, the JVM constructs an empty String array, and sends it to main. No one breaks any rules in this example. But you are correct. If the method defines that you must pass two integers, or three floats, then any call to that method must pass those parameters, otherwise it is a compiler error.