enum keyword

enum is a keyword which is used to represent a group of constants.

e.g.

enum MONTH {

  JAV,FEB,MAR,APRIL;

}

Enum Class

Enum is a class which is implicitly inherited by classes which is an enum. It is the base class for all java enums.It is because of this reason that an enum can not extend any other class as multiple inheritance is not allowed in java.

class Test {

}
// compile-time error as enum implicitly inherits Enum.
enum Month extends Test{
  // compile-time error
}

Enum class is present in java.lang package.

Enumeration Interface

Enumeration is an interface prsent in java.util package. It is used to get objects one by one from legacy collection classes like Vector.
i.e. It is used to iterate legacy collection classes.

e.g.

package com.masterjavatutorial;
import java.util.Enumeration;
import java.util.Vector;

public class Test {
	public static void main(String[] args) {
	   Vector v = new Vector();
	   v.add("Kiran");
	   v.add("Ramesh");
	   v.add("Raj");
	   Enumeration elements = v.elements(); 
	   while(elements.hasMoreElements()){
	 	System.out.println(elements.nextElement()); 
	   }
	}

}

Output of the above program is as below:

Kiran
Ramesh
Raj