public enum Weather{ Sunny,Rainy,Cloudy}
public String toString(){
return ; //这里怎么写才能输出是 Sunny或Rainy或Cloudy呢?
}

java 枚举类型怎么输出
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- threenewbee 2016-03-27 12:08关注
http://ideone.com/6ghz84
Sunny/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public enum Weather{ Sunny,Rainy,Cloudy} public static void main (String[] args) throws java.lang.Exception { // your code goes here String s = Weather.Sunny.toString(); System.out.println(s); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报