0

Can we call main method explicitly?

public static void main is called by jvm.

8th Jan 2018, 7:50 PM
Yogesh Sharma
Yogesh Sharma - avatar
3 Antworten
+ 2
It's a static method like any other, so once the program is executing you can call another main method using a static call (i.e. Class.main() )
8th Jan 2018, 8:22 PM
Dan Walker
Dan Walker - avatar
+ 1
public class Program { static int x = 0; public static void main(String[] args) { if (x < 20) { x++; main(args); } else System.out.println(x); } }
8th Jan 2018, 8:39 PM
John Wells
John Wells - avatar
0
Yes, anyone know how?
8th Jan 2018, 8:07 PM
Yogesh Sharma
Yogesh Sharma - avatar