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

Can you make a constructor final?

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

Amelia Martin

Studied at the University of Melbourne, Lives in Melbourne, Australia.
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-05 12:30:28

Charlotte Harris

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