class のコンストラクターが多すぎる場合は、これを使用して他のコンストラクターを呼び出すことができます。例 :
public class TeleScopePattern {
private final int servingSize;
private final int servings;
private final int calories;
private final int fat;
public TeleScopePattern(int servingSize, int servings) {
this(servingSize, servings, 0);
}
public TeleScopePattern(int servingSize, int servings, int calories) {
this(servingSize, servings, calories, 0);
}
public TeleScopePattern(int servingSize, int servings, int calories, int fat) {
this.servingSize = servingSize;
this.servings = servings;
this.calories = calories;
this.fat = fat;
}
}