Share on Google+Share on Google+

ENUM Types

In this SCJP section ,you will learn about ENUM Types of java

ENUM Types

A Enum type consist of a fixed set of constants. In java, you define an enum type by using the enum keyword. For example, you would specify a months-of-year enum type as:

public enum Year{

Example :

package SCJP;

enum Foods {

burger, frenchFries, , Coke,


public class EnumExample {

public static void main(String args[])


Foods fd;

fd = Foods.burger;

switch(fd) {

case burger:

System.out.println("You have decided to eat burger!");


case frenchFries:

System.out.println("You have decided to eat frenchFries");


case Coke:

System.out.println("You have decided to eat  Coke");


case Dosa:

System.out.println("You have decided to eat  Dosa");



System.out.println("I don't wanna eat any thing.");





Output :

C:\Program Files\Java\jdk1.6.0_18\bin>java EnumExample 

You chose burger!

Download Source Code

See Also : Enum Type


Posted on: July 5, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.