1. Enum is type-safe and has its own name-space.
We cannot assign any value other than specified in Enum Constants to Currency variable coin.
2. Enum is reference type like class or interface and you can define constructor, methods and variables inside java Enum which makes it more powerful than Enum in C and C++.
3. Values of enum constants can specify at the creation time:
However for to specify the values, we need to define a member variable and a constructor because PENNY (1) is calling a constructor which accepts int value.
4. Constructor of enum must be private any other access modifier will result in compilation error.
5. We can define methods in enum. To get the value associated with each coin, define a public getValue() method.
6. Enum constants are implicitly static and final and cannot be changed once created.
7. Enum can be used as an argument on switch statement and with "case:" like int or char primitive type.
8. Since constants defined inside Enum in Java are final you can safely compare them using "==" equality operator.
By the way comparing objects using == operator is not recommended, Always use equals() method or compareTo() method to compare Objects.
9. Java compiler automatically generates static values() method for every enum which returns array of Enum constants in the same order they have listed in enum.
10. We can override methods in enum.
Overriding toString() method inside enum to provide meaningful description for enums constants.
11. Two new collection classes EnumMap and EnumSet are added into collection package to support Java Enum.
These classes are high performance implementation of Map and Set interface.
12. private constructor of Enum is not allowed to create instance of enums by using new keyword. Enums constants can only be created inside Enums itself.
13. Instance of Enum is created when any Enum constants are first called or referenced in code (loading the enum in JVM).
14. Enum can implement the interface and override any method like normal class. It’s also worth noting that Enum in java implicitly implement both Serializable and Comparable interface.
15. We can define abstract methods inside enum and can provide different implementation for different instances of enum.