+ 1
Java method override
It is possible to override the main method in Java?
3 Respuestas
+ 2
Have you looked it up online? What would you like to do?
Have you looked here? You could even try it in the code playground.
https://www.sololearn.com/discuss/347605/?ref=app
https://sololearn.com/compiler-playground/W0uW3Wks8UBk/?ref=app
+ 1
There is the word "override" (not "hide") in the error below:
main.java:6: error: a() in main.B cannot override a() in main.A static void a() {} ^ overridden method is static,final 1 error error: compilation failed (exit status 1)
https://sololearn.com/compiler-playground/cdQgbBOT2T7h/?ref=app
0
main.B
Your compiler probably understands this code as
an inner class B in the implicitly declared class main (preview feature).
So main is not overridden, but it tries to override a()