Category: Java

values() method of Enum

All enums implicitly inherit java.lang.Enum class. values() is a static method of java.lang.Enum class. Hence, values() method is available in enum classes. values() method gives an array of enum class… Read more »

enum in switch statement

enum concept was introduced in java 1.5 . from 1.5 version in Java, switch statements were allowed to use enums. package com.masterjavatutorial; public enum MONTHS { JAN,FEB,MAR,APR,MAY; }… Read more »

toString() in enum

Default implementation of toString() method lies in Object class. Object is the super class of all classes. If a class does not override toString() method, then Object class toString() method… Read more »

Rules for Syntax of enum

enum concept was introduced in java 1.5. enum is used to represent a group of constants. A Simple enum class can be declared as below: package com.masterjavatutorial; public enum MONTHS… Read more »

Main() Method in enum

enum can have public static void main() method . main() method in enum executes just like its execution in any other class. The below example explains the main method in… Read more »