QuesHub > 函数 > 在线 > 测试 > ASK DETAIL

Can you make a constructor final in Java?

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

Isabella Davis

Studied at the University of Amsterdam, Lives in Amsterdam, Netherlands.
So making a constructor final is not required, so it is not used with constructor. When you set a method as final, it means : "You don't want any class override it", but constructor by JLS definition can't overridden,so it is clean. We can't make constructor to be final because constructor is never inherited.
2023-05-07 12:30:36

Oliver Kim

QuesHub.com delivers expert answers and knowledge to you.
So making a constructor final is not required, so it is not used with constructor. When you set a method as final, it means : "You don't want any class override it", but constructor by JLS definition can't overridden,so it is clean. We can't make constructor to be final because constructor is never inherited.
ask:3,asku:1,askr:137,askz:21,askd:152,RedisW:0askR:3,askD:0 mz:hit,askU:0,askT:0askA:4