Click here to watch in Youtube :
https://www.youtube.com/watch?v=_hAxSheXrCw&list=UUhwKlOVR041tngjerWxVccw
Level.java
https://www.youtube.com/watch?v=_hAxSheXrCw&list=UUhwKlOVR041tngjerWxVccw
Level.java
public enum Level
{
HIGH, MEDIUM, LOW
}
EnumDemo.java public class EnumDemo
{
public static void main(String[] args)
{
/*
* We can obtain an array of all the possible values
* of a Java enum type by calling its static
* values() method.
*
* All enum types get a static values() method
* automatically by the Java compiler.
*
* Notice the output how the names of the constants
* themselves are printed out. This is one area
* where Java enums are different than static final
* constants.
*/
Level[] levelArray = Level.values();
for (Level level : levelArray)
{
System.out.println(level);
}
}
}
Output HIGH
MEDIUM
LOW
Click the below link to download the code:
No comments:
Post a Comment