Here you can find the source of valueOf(Class
Parameter | Description |
---|---|
en | enum |
name | name of item |
public static <T extends Enum<T>> T valueOf(Class<T> en, String name)
//package com.java2s; //License from project: LGPL public class Main { /**//from w w w . j ava 2 s . co m * Gets the value of an enum from a name. The name can be null, causing * the return value to be null. * * @param en enum * @param name name of item * @return value or null */ public static <T extends Enum<T>> T valueOf(Class<T> en, String name) { if (name == null) return null; try { return Enum.valueOf(en, name); } catch (IllegalArgumentException e) { return null; } } }