public String monday; public String tuesday; public String wensday; public String thursday; public String friday; public String saturday; public String sunday;
或者你想定义成公用的变量,以为其它类来使用:
public static final String monday = "1"; public static final String tuesday = "2"; public static final String wensday = "3"; public static final String thursday = "4"; public static final String friday = "5"; public static final String saturday = "6"; public static final String sunday = "7";
如果你已经厌倦了上面的代码, 那就用枚举类型实现吧,代码如下:
public enum Weekday { monday,tuesday,wensday,thursday,friday,saturday,sunday }
哇哦,是不是很cool,哈哈! ………………………………..等等,为什么只有变量没有赋值呢?
参考资料:
http://www.cnblogs.com/frankliiu-java/archive/2010/12/07/1898721.html