QuesHub > 声明 > 方法 > 也不 > ASK DETAIL

Can a main () method be declared final?

Harper Adams | 2023-05-05 12:30:28 | page views:1752
I'll answer
Earn 20 gold coins for an accepted answer.20 Earn 20 gold coins for an accepted answer.
40more

Elijah Price

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

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.
ask:3,asku:1,askr:137,askz:21,askd:152,RedisW:0askR:3,askD:0 mz:hit,askU:0,askT:0askA:4