public enum Weather{ Sunny,Rainy,Cloudy}
public String toString(){
return ; //這裡怎麼寫才能輸出是 Sunny或Rainy或Cloudy呢?
}
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);
}
}