Category: Java

Enum valueOf() Method

valueOf() is a static method of java.lang.Enum which takes argument as String. valueOf() method returns the enum constant for the specified string value which is passed as an argument in… Read more »

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. MONTHS.java package com.masterjavatutorial; public enum MONTHS { JAN,FEB,MAR,APR,MAY; } Test.java… 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 »