public enum Weather{ Sunny,Rainy,Cloudy}
public String toString(){
return ; //这里怎么写才能输出是 Sunny或Rainy或Cloudy呢?
}
/* 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);
}
}
sorry,看错了。
根本什么都不要写就是了。
Weather w = Weather.Sunny;
String s = w.Sunny.toString();
System.out.println(s);
这样是不是清楚一些
return this.toString();