Here you can find the source of valueOf(Class
public final static <T extends Enum<T>> T valueOf(Class<T> enumType, int ordinal)
//package com.java2s; //License from project: Open Source License public class Main { public final static <T extends Enum<T>> T valueOf(Class<T> enumType, int ordinal) { for (T value : enumType.getEnumConstants()) { if (value.ordinal() == ordinal) { return value; }/*w w w . j ava 2 s . c om*/ } return null; } }