Get a field object specified by name
The getField method of Class class can be used for getting a given field object of a class.
import java.lang.reflect.Field;
public class ClazzUtil {
public static void main(String[] args) throws SecurityException, NoSuchFieldException{
Field field = Integer.class.getField("TYPE");
System.out.println(field.getName());
}
}
Tags: Class, Class examples, java.lang, java.lang.Class
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply