欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

java枚举类实例应用

时间:2023-07-07

public enum DetailEnum { SYSTEM("1","社区服务"), ConSULTING("2","咨询服务"), LIVE("3","直播服务"), ORDER("4","订单状态服务"), SHOPPING("5","商城服务"), Mail("7","邮件服务"); private String type; //类型 private String desc; //描述 private DetailEnum (String type,String desc){ this.type=type; this.desc=desc; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; }}class Test{ public static void main(String[] args){ DetailEnum detail=DetailEnum .SYSTEM; //每个枚举成员实际上是一个枚举实例 System.out.println(detail.getType()); System.out.println(detail.getDesc()); }}

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。