Skip to content
February 14, 2009 / Narayan

Enum (eration) in Java

Here you can see the structure of Enum class in java. This class have their own rules and regulation.In this class there is no use of public except in the method value and class access because it doesn’t give any access to client. Some changable user-defined are written in italics.

For enum define , Just use below syntax

//pseudo code

public enum EnumName { ... }

Then after the class defining there is a access of only one attribute that is :

//pseudo code

private final type value;

As there is only one attribute value, which can access some of the listed values in given form:

//pseudo code

SymbolicNamen(value n);

For constructor in enum class:

//pseudo code
Enum name(datatype v){
value = v;

Now for invoking the given symbol or value a method value() must be defined in default.

//pseudo code
public datatype value(){ ...  };

A simple enum class is given below:
public enum Example {




CS("Compuer Science"),




private final String value;


Example(String v){

value = v;


//public accessor method

public String value(){

return value;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: