Java Enum from Ordinal fromOrdinal(E[] values, int ordinal)

Here you can find the source of fromOrdinal(E[] values, int ordinal)

Description

from Ordinal

License

Open Source License

Declaration

public static <E> E fromOrdinal(E[] values, int ordinal) 

Method Source Code

//package com.java2s;
/* USE THIS FILE ACCORDING TO THE COPYRIGHT RULES IN LICENSE.TXT WHICH IS PART OF THE SOURCE CODE PACKAGE */

public class Main {
    public static <E> E fromOrdinal(E[] values, int ordinal) {
        return ordinal >= 0 && ordinal < values.length ? values[ordinal] : values[0];
    }//  w  w w.  j a va 2  s.  co  m
}

Related

  1. fromOrdinal(Class enumClass, int ordinal)
  2. fromOrdinal(Class enumClass, Integer value)