Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling main method inside main in java

Can we call main method inside main?

public static void main(String[] args) {
    main({"a","b","c"});
}

Tried to google.Can't find the link. Sorry if the question is trivial

like image 288
abc Avatar asked Nov 27 '22 21:11

abc


2 Answers

You can but using the correct format

main(new String[] {"a","b","c"});

should give StackOverFlowError (not tested)

like image 114
Reimeus Avatar answered Nov 30 '22 23:11

Reimeus


You will get StackOverFlowError. If you call endless recursive calls/deep function recursions.

Thrown when a stack overflow occurs because an application recurses too deeply.

You need to pass String array like

main(new String[] {"a","b","c"});
like image 30
Abimaran Kugathasan Avatar answered Nov 30 '22 22:11

Abimaran Kugathasan