How to Use an Enum Inside a Class in Java


In this example we will show you how to use an enum inside a class in Java.

Source Code

package com.beginner.examples;


public class EnumInClass { 
  enum Score { // enum
    A,
    B,
    C
  }

  public static void main(String[] args) { 
    Score s = Score.A; 
    System.out.println(s);
  } 
}

Output:

A
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments