java.lang.Object | ||
↳ | java.lang.reflect.AccessibleObject | |
↳ | java.lang.reflect.Field |
This class represents a field. Information about the field can be accessed, and the field's value can be accessed dynamically.
[Expand]
Inherited Constants
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.lang.reflect.Member
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Indicates whether or not the specified
object
is equal to this
field.
|
||||||||||
|
Returns the value of the field in the specified object.
|
||||||||||
|
Returns, for this element, the annotation with the specified type, or
null
if no annotation with the specified type is present
(including inherited annotations).
|
||||||||||
|
Returns the value of the field in the specified object as a
boolean
.
|
||||||||||
|
Returns the value of the field in the specified object as a
byte
.
|
||||||||||
|
Returns the value of the field in the specified object as a
char
.
|
||||||||||
|
Returns, for this element, all annotations that are explicitly declared
(not inherited).
|
||||||||||
|
Returns the class that declares this field.
|
||||||||||
|
Returns the value of the field in the specified object as a
double
.
|
||||||||||
|
Returns the value of the field in the specified object as a
float
.
|
||||||||||
|
Returns the generic type of this field.
|
||||||||||
|
Returns the value of the field in the specified object as an
int
.
|
||||||||||
|
Returns the value of the field in the specified object as a
long
.
|
||||||||||
|
Returns the modifiers for this field.
|
||||||||||
|
Returns the name of this field.
|
||||||||||
|
Returns the value of the field in the specified object as a
short
.
|
||||||||||
|
Return the
Class
associated with the type of this field.
|
||||||||||
|
Returns an integer hash code for this field.
|
||||||||||
|
Indicates whether or not this element has an annotation with the
specified annotation type (including inherited annotations).
|
||||||||||
|
Indicates whether or not this field is an enumeration constant.
|
||||||||||
|
Indicates whether or not this field is synthetic.
|
||||||||||
|
Sets the value of the field in the specified object to the value.
|
||||||||||
|
Sets the value of the field in the specified object to the
boolean
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
byte
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
char
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
double
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
float
value.
|
||||||||||
|
Set the value of the field in the specified object to the
int
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
long
value.
|
||||||||||
|
Sets the value of the field in the specified object to the
short
value.
|
||||||||||
|
Returns the string representation of this field, including the field's
generic type.
|
||||||||||
|
Returns a string containing a concise, human-readable description of this
field.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.reflect.AccessibleObject
|
|||||||||||
From class
java.lang.Object
|
|||||||||||
From interface
java.lang.reflect.AnnotatedElement
|
|||||||||||
From interface
java.lang.reflect.Member
|
Indicates whether or not the specified
object
is equal to this
field. To be equal, the specified object must be an instance of
Field
with the same declaring class, type and name as this field.
object | the object to compare |
---|
true
if the specified object is equal to this method,
false
otherwise
Returns the value of the field in the specified object. This reproduces
the effect of
object.fieldName
If the type of this field is a primitive type, the field value is automatically boxed.
If this field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns, for this element, the annotation with the specified type, or
null
if no annotation with the specified type is present
(including inherited annotations).
annotationType | the type of the annotation to search for |
---|
null
Returns the value of the field in the specified object as a
boolean
. This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the value of the field in the specified object as a
byte
.
This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the value of the field in the specified object as a
char
.
This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns, for this element, all annotations that are explicitly declared (not inherited). If there are no declared annotations present, this method returns a zero length array.
Returns the class that declares this field.
Returns the value of the field in the specified object as a
double
. This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the value of the field in the specified object as a
float
. This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the generic type of this field.
GenericSignatureFormatError | if the generic field signature is invalid |
---|---|
TypeNotPresentException | if the generic type points to a missing type |
MalformedParameterizedTypeException | if the generic type points to a type that cannot be instantiated for some reason |
Returns the value of the field in the specified object as an
int
.
This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the value of the field in the specified object as a
long
.
This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the name of this field.
Returns the value of the field in the specified object as a
short
. This reproduces the effect of
object.fieldName
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
object | the object to access |
---|
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Return the
Class
associated with the type of this field.
Returns an integer hash code for this field. Objects which are equal return the same value for this method.
The hash code for a Field is the exclusive-or combination of the hash code of the field's name and the hash code of the name of its declaring class.
Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).
annotationType | the type of the annotation to search for |
---|
true
if the annotation exists,
false
otherwise
Indicates whether or not this field is an enumeration constant.
true
if this field is an enumeration constant,
false
otherwise
Indicates whether or not this field is synthetic.
true
if this field is synthetic,
false
otherwise
Sets the value of the field in the specified object to the value. This
reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the field type is a primitive type, the value is automatically unboxed. If the unboxing fails, an IllegalArgumentException is thrown. If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
boolean
value. This reproduces the effect of
object.fieldName =
value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
byte
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
char
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
double
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
float
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Set the value of the field in the specified object to the
int
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
long
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Sets the value of the field in the specified object to the
short
value. This reproduces the effect of
object.fieldName = value
If this field is static, the object argument is ignored.
Otherwise, if the object is
null
, a NullPointerException is
thrown. If the object is not an instance of the declaring class of the
method, an IllegalArgumentException is thrown.
If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
If the value cannot be converted to the field type via a widening conversion, an IllegalArgumentException is thrown.
object | the object to access |
---|---|
value | the new value |
NullPointerException |
if the object is
null
and the field is non-static
|
---|---|
IllegalArgumentException | if the object is not compatible with the declaring class |
IllegalAccessException | if this field is not accessible |
Returns the string representation of this field, including the field's generic type.
Returns a string containing a concise, human-readable description of this field.
The format of the string is:
For example:
public static java.io.InputStream
java.lang.System.in