当前位置: 网站首页 >> 手游 > >> 正文

今日快看!c语言enum用法_enum用法

时间:2023-04-29 07:58:58 来源:互联网


【资料图】

1、下面是一个例举的例子:public enum WeekDay { SUN(1, "Sunday", "SUN"), MON(2, "Monday", "MON"), TUE(3, "Tuesday", "TUE"), WED(4, "Wednesday", "WED"), THU(5, "Thursday", "THU"), FRI(6, "Friday", "FRI"), SAT(7, "Saturday", "SAT"); private String shortName; private String fullName; private int dayOfWeek; private WeekDay(int dayOfWeek, String name, String sname) { this.dayOfWeek = dayOfWeek; fullName = name; shortName = sname; } public static WeekDay getDay(int dayIndex) { switch (dayIndex) { case 1: return SUN; case 2: return MON; case 3: return TUE; case 4: return WED; case 5: return THU; case 6: return FRI; case 7: return SAT; } return null; } public String getShortName() { return shortName; } public int getDayOfWeek() { return dayOfWeek; } @Override public String toString() { return fullName; }}。

本文到此分享完毕,希望对大家有所帮助。

关键词:
x 广告
x 广告

Copyright   2015-2022 南极游戏网版权所有   备案号:粤ICP备2022077823号-13   联系邮箱: 317 493 128@qq.com