+ 1
Java method override
It is possible to override the main method in Java?
7 Respostas
+ 4
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
+ 3
Ismael saka Ismael please don't hijack another person's thread with an unrelated topic, that's not nice.
You can start the Web courses and learn for free. Also, search the forum and code playground for awesome resources.
+ 2
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()
+ 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
+ 1
There is the separate class with the main method below:
https://sololearn.com/compiler-playground/cHk3G6YVTdam/?ref=app
+ 1
No brother you can't override main method.
Overriding methods are those with same name and parameter but different implementation
+ 1
Ñicholas Junior same thing as Ismael, don't write unrelated things in someone else's post.