本文介绍了公共枚举中的主要方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨此代码有什么问题?
我无法编译.

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());
        }
    }
}
解决方案



hiwhat 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());
        }
    }
}
解决方案



这篇关于公共枚举中的主要方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 06:26