Can a main () method be declared final?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Works at PayPal, Lives in San Jose, CA
Sure, it can be declared final! It doesn't matter if it is declared final, the JVM will still find it and run it, and the compiler doesn't care. Yes We can declare main method final. If we make this final it can not be override.Hence we can't use it in its child class.
2023-05-09 12:30:28
评论(499)
Helpful(122)
Helpful
Helpful(2)

Lucas Brown
QuesHub.com delivers expert answers and knowledge to you.
Sure, it can be declared final! It doesn't matter if it is declared final, the JVM will still find it and run it, and the compiler doesn't care. Yes We can declare main method final. If we make this final it can not be override.Hence we can't use it in its child class.