Return to Snippet

Revision: 35415
at November 8, 2010 01:50 by studioevoque

Initial Code
public class EnumTester {
    enum Color { RED, GREEN, BLUE };

    public static void main(String[] args) {

        int selection = 1;
        Color selectedColor = Color.values()[ selection ];

        System.out.println("Selected color ="+selectedColor);

Initial URL

Initial Description
A simple way to get the enum indicated by its ordinal value.

Initial Title
Get enum from integer value (ordinal)

Initial Tags

Initial Language