Java中的构造函数链接(带示例)

Post Link : Constructor Chaining In Java with Examples

Calling a constructor from the another constructor of same class is known as Constructor chaining. The real purpose of Constructor Chaining is that you can pass parameters through a bunch of different constructors, but only have the initialization done in a single place. This allows you to maintain your initialization from a single location, while providing multiple constructors to the user. If we don’t chain, and two different constructors require a specific parameter, you will have to initialize that parameter twice, and when the initialization changes, you’ll have to change it in every constructor, instead of just the one.

Java中的构造函数链接(带示例)

Click to view example

from: https://dev.to//skptricks/constructor-chaining-in-java-with-examples-4ppp