Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi what is wrong with this code?
i can not compile it.
public enum Days{
    monady(1),
    tuesday(2),
    wedenesday(3),
    thursday(4),
    friday(5),
    saturday(6),
    sunday(7);
    private final int dayValue;
    Days(int count)
    {
        this.dayValue=count;
    }
    public int getDayValue()
    {
        return dayValue;
    }
    public static void main(String[] args)
    {
        for(Days day:Days.values())
        {
             System.out.println("The day is "+day+" ,The value of day is:"+day.getDayValue());
        }
    }
}
Posted
Updated 26-Jun-11 2:39am
v3
Comments
Richard MacCutchan 26-Jun-11 11:26am    
What errors do you get when you compile it?

I have just compiled and run this code without problems. What exactly happens when you try?
 
Share this answer
 
I don't think you can actually define anything other than constants in an enum. I could be wrong, but the tutorials seem to agree with me: Enum Types[^]
So trying to include your whole program in an enum is always going to end in tears...
 
Share this answer
 
Comments
Reza Oruji 26-Jun-11 8:48am    
please see this page
http://download.oracle.com/javase/tutorial/java/javaOO/enum.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900