|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
A field is a class, interface, or enum with an associated value. Methods in thejava.lang.reflect.Fieldclass can retrieve information about the field, such as its name, type, modifiers, and annotations. (The section Examining Class Modifiers and Types in the Classes lesson describes how to retrieve annotations.) There are also methods which enable dynamic access and modification of the value of the field. These tasks are covered in the following sections:
- Obtaining Field Types describes how to get the declared and generic types of a field
- Retrieving and Parsing Field Modifiers shows how to get portions of the field declaration such as
publicortransient- Getting and Setting Field Values illustrates how to access field values
- Troubleshooting describes some common coding errors which may cause confusion
When writing an application such as a class browser, it might be useful to find out which fields belong to a particular class. A class's fields are identified by invoking
Class.getFields(). ThegetFields()method returns an array ofFieldobjects containing one object per accessible public field.A public field is accessible if it is a member of either:
- this class
- a superclass of this class
- an interface implemented by this class
- an interface extended from an interface implemented by this class
A field may be a class (instance) field, such as
java.io.Reader.lock, a static field, such asjava.lang.Integer.MAX_VALUE, or an enum constant, such asjava.lang.Thread.State.WAITING.