java.lang.reflect.Field (JDK 1.1)
This class represents a field of a class. Instances of Field are obtained by calling the getField() and related methods of java.lang.Class. Field implements the Member interface, so once you have obtained a Field object, you can use getName(), getModifiers(), and getDeclaringClass() to determine the name, modifiers, and class of the field. Additionally, getType() returns the type of the field.
The set() method sets the value of the represented field for a specified object to a given value. (If the represented field is static, then no object need be specified for it to be set upon, of course.) If the field is of a primitive type, its value can be specified using a wrapper object of type Boolean, Integer, and so on, or it can be set using the setBoolean(), setInt(), and related methods.
Similarly, the get() method queries the value of the represented field for a specified object and returns the field value as an Object. Various other methods query the field value and return it as various primitive types.
public final classFieldextends Object implements Member { //No Constructor//Public Instance Methodspublic booleanequals(Objectobj); //Overrides Objectpublic native Objectget(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native booleangetBoolean(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native bytegetByte(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native chargetChar(Objectobj) throws IllegalArgumentException, IllegalAccessException; public ClassgetDeclaringClass(); //From Memberpublic native doublegetDouble(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native floatgetFloat(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native intgetInt(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native longgetLong(Objectobj) throws IllegalArgumentException, IllegalAccessException; public native intgetModifiers(); //From Memberpublic StringgetName(); //From Memberpublic native shortgetShort(Objectobj) throws IllegalArgumentException, IllegalAccessException; public ClassgetType(); public inthashCode(); //Overrides Objectpublic native voidset(Objectobj, Objectvalue) throws IllegalArgumentException, IllegalAccessException; public native voidsetBoolean(Objectobj, booleanz) throws IllegalArgumentException, IllegalAccessException; public native voidsetByte(Objectobj, byteb) throws IllegalArgumentException, IllegalAccessException; public native voidsetChar(Objectobj, charc) throws IllegalArgumentException, IllegalAccessException; public native voidsetDouble(Objectobj, doubled) throws IllegalArgumentException, IllegalAccessException; public native voidsetFloat(Objectobj, floatf) throws IllegalArgumentException, IllegalAccessException; public native voidsetInt(Objectobj, inti) throws IllegalArgumentException, IllegalAccessException; public native voidsetLong(Objectobj, longl) throws IllegalArgumentException, IllegalAccessException; public native voidsetShort(Objectobj, shorts) throws IllegalArgumentException, IllegalAccessException; public StringtoString(); //Overrides Object}
Returned By:
Class.getDeclaredField(), Class.getDeclaredFields(), Class.getField(), Class.getFields()