-2

Please help me by answering the difference between Enum and enum in java. I tried searching the various answers present in this below link but it seems to be not much helpful.

difference between Enum and enum

Community
  • 1
  • 1
Siddhartha
  • 492
  • 1
  • 5
  • 15
  • http://www.xyzws.com/javafaq/what-is-the-difference-between-an-enum-type-and-javalangenum/186 (from google answers) –  May 21 '17 at 12:50
  • see also http://stackoverflow.com/a/15734503/180100 –  May 21 '17 at 12:51

3 Answers3

5

java.lang.Enum is an abstract class, it is the common base class of all Java enumeration types while enum it's a category of classes that extend the Enum base class.

Itzik Shachar
  • 744
  • 5
  • 16
4

enum is a keyword used to define an enumerated type, like class is used to define a class:

public enum Season { WINTER, SPRING, SUMMER, AUTUMN }

Enum is the simple name of the java.lang.Enum class, which is the superclass of all enumerated types defined using the enum keyword.

They're not really comparable. They're different things. enum is to Enum what the keyword class is to java.lang.Object.

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0

enum (a datatype) extends the abstract class Enum under the hood. This will give you access to methods like ordinal(), found in Enum class.

From Enum abstract class definition(the first line):

This is the common base class of all Java language enumeration types.

An example:

public class MyClass {
    public static void main(String args[]) {
      System.out.println(Color.BLUE.ordinal()); //prints 1
    }
}

enum Color{
    RED, BLUE, YELLOW
}

BONUS:
You might want to check out this. There are 3 short videos.

Enjoy and cheers.

jumping_monkey
  • 5,941
  • 2
  • 43
  • 58