Enum in Java

Enum:

To Create Enum:

public enum Degree  {   BE, BCA, MBBS };

}

By default the first value is set to   0  ,

else If you set the first value as 5  then it will automatically assign second value = 6

How to get int value of enum:

ordinal() – It is used to get the int value of the enum type

Ex: int i =  Degree.BE.ordinal

TO BE CONTINUED ..…….…….

 


Advertisements
  1. Leave a comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: