java - Why aren't byte arguments recognized as integers? -


i have following enum:

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 month      private months(byte numberofdays){         this.days = numberofdays;     }//end constructor      public byte getdays(){         return this.days;     }//end method getdays }//end enum months 

it gives me error says "the constructor months(int) undefined" although passing valid byte arguments. what doing wrong?

the simplest solution accept int value

private months(int numberofdays){     this.days = (byte) numberofdays; } 

btw non-static fields should in camelcase not upper_case

also feb has 29 days in years.

public static boolean isleapyear(int year) {     // assume gregorian calendar time     return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); }  public int getdays(int year) {     return days + (this == feb && isleapyear(year) ? 1 : 0); }  

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -