printing out enums java

Solutions on MaxInterview for printing out enums java by the best coders in the world

showing results for - "printing out enums java"
Simon
29 Mar 2018
1/**
2 * A Java enum toString example.
3 * @author alvin alexander, alvinalexander.com
4 */
5public class JavaEnumToStringExample
6{
7
8  public static void main(String[] args)
9  {
10    // loop through the enum values, calling the
11    // enum toString method for each enum constant
12    for (Day d: Day.values())
13    {
14      System.out.println(d);
15    }
16  }
17}
18
19enum Day
20{
21  SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY 
22}
23