| 編集の要約なし | 編集の要約なし | ||
| 1行目: | 1行目: | ||
| * 列挙型 (enum type) とは、フィールドに割り当てられる値(3つ以上)を列挙して限定する仕組み | * 列挙型 (enum type) とは、フィールドに割り当てられる値(3つ以上)を列挙して限定する仕組み | ||
| * 2つだけなら boolean型の true と false で表現できる | * 2つだけなら boolean型の true と false で表現できる | ||
|  # AccountType.java | |||
|  enum AccountType { | |||
|      FUTSU, TOUZA, TEIKI; | |||
|  } | |||
|  public class Account { | |||
|      private String number; | |||
|      private AccountType type; | |||
|      private int balance; | |||
|      public Account (String number, AccountType type) { ... } | |||
2019年7月2日 (火) 10:44時点における版
- 列挙型 (enum type) とは、フィールドに割り当てられる値(3つ以上)を列挙して限定する仕組み
- 2つだけなら boolean型の true と false で表現できる
# AccountType.java
enum AccountType {
    FUTSU, TOUZA, TEIKI;
}
public class Account {
    private String number;
    private AccountType type;
    private int balance;
    public Account (String number, AccountType type) { ... }