public class meiju {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
WeekDays x = WeekDays.SUN;
System.out.println(x.name());
System.out.println(WeekDays.valueOf("SUN"));
System.out.println(WeekDays.valueOf("SUN").toString());
}
public enum WeekDays{
SUN,MON,TUE,WED,THR,FRI,SAT;
}
}
想问下System.out.println(WeekDays.valueOf("SUN"));
System.out.println(WeekDays.valueOf("SUN").toString());
这两句的区别。 我输出的结果都是SUN 问下什么区别。
还有为什么传入的值要写"SUN"字符串。 直接写 SUN 就会报错? |