+ 1

Java method override

It is possible to override the main method in Java?

12th Jul 2025, 7:39 AM
Evgeniy Kazban
Evgeniy Kazban - avatar
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
12th Jul 2025, 8:36 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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.
13th Jul 2025, 10:10 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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()
12th Jul 2025, 6:52 PM
zemiak
+ 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
12th Jul 2025, 11:37 AM
Evgeniy Kazban
Evgeniy Kazban - avatar
+ 1
There is the separate class with the main method below: https://sololearn.com/compiler-playground/cHk3G6YVTdam/?ref=app
13th Jul 2025, 9:52 AM
Evgeniy Kazban
Evgeniy Kazban - avatar
+ 1
No brother you can't override main method. Overriding methods are those with same name and parameter but different implementation
14th Jul 2025, 1:38 AM
Safiullah Mohammadi
Safiullah Mohammadi - avatar
+ 1
Ñicholas Junior same thing as Ismael, don't write unrelated things in someone else's post.
14th Jul 2025, 6:15 AM
Ausgrindtube
Ausgrindtube - avatar