We create a method with argument. eg: void sample(int a) ...Can i call to sample method without int
argument ? No , we will get error......then how JVM call main() without string array argument ?
Who says the main()
method is called without any argument? An empty String
array is passed to adhere to the method signature. If you pass any other arguments to the program, then they are added to this array.
public static void main(String[] args) {
System.out.println(args);
System.out.println(args.length);
}
O/P :
[Ljava.lang.String;@5d888759
0