枚举类型在Java中使用

public enum AccountType {

Cash("现金"),
DisCash("现金"),
Margin("转账"),
DisMargin("转账");
private String value;

private AccountType(String value) {
    this.value = value;
}
public String getValue() {
    return value;
}

public static void main(String[] args) {
    System.out.println(AccountType.Cash.getValue());

    if("现金".equals(AccountType.Cash.getValue())){
        System.out.println("我用现金结账");
    }
}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章