Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
オブジェクト生成方法、JavaBeans パターンサンプル
class NutritionFacts {
private int servingSize = -1; // 必須
private int servings = -1; // 必須
private int calories = 0; // オプション
private int fat = 0; // オプション
private int sodium = 0; // オプション
private int carbohydrate = 0; // オプション
public void setServingSize(int servingSize) {
this.servingSize = servingSize;
}
public void setServings(int servings) {
this.servings = servings;
}
public void setCalories(int calories) {
this.calories = calories;
}
public void setFat(int fat) {
this.fat = fat;
}
public void setSodium(int sodium) {
this.sodium = sodium;
}
public void setCarbohydrate(int carbohydrate) {
this.carbohydrate = carbohydrate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment