1. 程式人生 > >JAVA 列舉型別簡單應用

JAVA 列舉型別簡單應用

public enum Music 
{
	Because_Of_You("/resource/Because_Of_You.wav"),
	Just_A_Kiss("/resource/Just_A_Kiss.wav"),
	Angel_Baby("/resource/Angel_Baby.wav");
	
	private String url = null;
	
	private Music(String url)
	{
	  this.url = url;	
	}
	
	public  String getUrl()
	{
		return url;
	}

}

public class MusicTest 
{
    public static void  main(String[] args)
    {
        for(Music m :Music.values())
        {
            System.out.println(m.getUrl());
        }
    }
}