+ 3

What is the use of enum keyword

31st May 2017, 1:41 PM
indumohara
indumohara - avatar
2 ответов
+ 14
Enum serves as a type of fixed number of constants and can be used at least for two things constant public enum Month { JANUARY, FEBRUARY, ... } This is much better than creating a bunch of integer constants. creating a singleton public enum Singleton { INSTANCE // init }; You can do quite interesting things with enums, look at http://javarevisited.blogspot.com/2011/08/enum-in-java-example-tutorial.html Also look at the http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html -stackoverflow
31st May 2017, 2:46 PM
Kailash Loncha
Kailash Loncha - avatar
31st May 2017, 1:45 PM
Thanh Le
Thanh Le - avatar