MBZ
MBZ

Reputation: 27632

convert a Class attribute to Field

Can I convert a Class attribute to appropriate Field class?

For example consider the following code:

class Test {
    Integer A;

    void init() {
        Field fA = ???;
    }
}

I want fA to describe Test.A.

Upvotes: 0

Views: 321

Answers (1)

shyam
shyam

Reputation: 9368

Field fA = Test.class.getDeclaredField("A");

Upvotes: 3

Related Questions