Enum constructor in Java

The java.lang.Enum class is the common base class of all Java language enumeration types.

Here is the Enum constructor

Sr.NoConstructor & Description
1protected Enum(String name, int ordinal)
This is the single constructor.

The following is an example wherein we can create an Enum constructors −


 Live Demo

enum Devices {
   LAPTOP(200), MOBILE(700), TABLET(400), DESKTOP(150);
   private int count;
   Devices(int p) {
      count = p;
   int count() {
   return count;
public class Demo {
   public static void main(String[] args) {
      Devices d;
      System.out.println("Count of Mobile devices : " + Devices.MOBILE.count() + " units
");    } }


Count of Mobile devices : 700 units
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know