In this example we will show the method to loop through an enum in Java.
Source Code
package com.beginner.examples;
enum Score {
A,
B,
C
}
public class LoopEnum {
public static void main(String[] args) {
for (Score s : Score.values()) { // loop through an enum
System.out.println(s);
}
}
}
Output:
A
B
C