Fields (The Java™ Tutorials > The Reflection API > Members)
Maybe your like
The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.See Dev.java for updated tutorials taking advantage of the latest releases.See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
FieldsA field is a class, interface, or enum with an associated value. Methods in the java.lang.reflect.Field class 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 public or transient
- 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(). The getFields() method returns an array of Field objects 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 as java.lang.Integer.MAX_VALUE , or an enum constant, such as java.lang.Thread.State.WAITING.
« Previous • Trail • Next »About Oracle | Contact Us | Legal Notices | Terms of Use | Your Privacy Rights
Copyright © 1995, 2024 Oracle and/or its affiliates. All rights reserved.
Previous page: Members Next page: Obtaining Field TypesTag » What Are Fields In Java
-
Java Fields
-
Field (Java Platform SE 8 ) - Oracle Help Center
-
What Is The Difference Between Field, Variable ... - GeeksforGeeks
-
Java Fields Vs. Java Methods - Video & Lesson Transcript
-
Java Fields: Types & Examples
-
Java: What Is A Field? - Quora
-
What Is A Field In Java ? - Examples Java Code Geeks - 2022
-
[PDF] Class Fields, Constructors, And Methods
-
Java Fields And Methods - JavaPointers
-
Java For Complete Beginners - Field Variables
-
Data Fields Of Java Objects - MATLAB & Simulink - MathWorks
-
2.7. Parts Of A Java Class - Runestone Academy
-
Fields And Methods In Java - RoseIndia.Net
-
What Is The Difference Between Field, Variable ... - Stack Overflow