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

Can you declare the main method as final in Java?

Lucas Patel | 2023-05-05 12:30:36 | page views:1782
I'll answer
Earn 20 gold coins for an accepted answer.20 Earn 20 gold coins for an accepted answer.
40more

Zoe Allen

Studied at the University of Johannesburg, Lives in Johannesburg, South Africa.
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-15 12:30:36

Zoe Reed

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