【发布时间】:2013-08-18 13:57:33
【问题描述】:
我有以下枚举:
public enum Months {
JAN(31),
FEB(28),
MAR(31),
APR(30),
MAY(31),
JUN(30),
JUL(31),
AUG(31),
SEP(30),
OCT(31),
NOV(30),
DEC(31);
private final byte DAYS; //days in the month
private Months(byte numberOfDays){
this.DAYS = numberOfDays;
}//end constructor
public byte getDays(){
return this.Days;
}//end method getDays
}//end enum Months
它给了我一个错误,说 “构造函数 Months(int) 未定义” 尽管我传递了一个有效的字节参数。 我做错了什么?
【问题讨论】:
-
你传入的是整数,但你的构造函数需要字节
标签: java constructor enums arguments byte