1

Where can I find a document to understand about JAVA/Reflection like below code ?

Field.class.getDeclaredField("modifiers")

What is getDeclaredField does?

What is a term "modifiers" do ?

I have seen reflection code in action from here

2 Answers 2

4

From the javadoc which should be the first place you look when something is puzzling you.

Sign up to request clarification or add additional context in comments.

Comments

0

What is getDeclaredField does?

The method getDeclaredField(String name)

Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.


What is a term "modifiers" do ?

"modifiers" here represents the name of the field to retrieve, as stated into the javadoc:

The name parameter is a String that specifies the simple name of the desired field.


To summarize Field.class.getDeclaredField("modifiers"), will get by reflection the field modifiers from the class Field.

 public final class Field extends AccessibleObject implements Member {
      ...
      private int                 modifiers; <-- this
      ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.