Why can't this() and super() both be used together in a constructor?

后端 未结 9 635
栀梦
栀梦 2020-12-12 17:17

Why can\'t this() and super() both be used together in a constructor?

What is the reason for incorporating such a thing?

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 18:01

    Because if you use this() and super() together in a constructor it will give compile time error. Because this() and super() must be the first executable statement. If you write this() first than super() will become the second statement and vice-versa. That's why we can't use this() and super() together.

提交回复
热议问题