Mehdi Zayene
Mehdi Zayene

Reputation: 37

How to get nested classes from a class from the parent one via Java Reflection

Is it possible to get access to a nested class fields from the parent one via Java reflection ? I spent a lot of time reading the documentation and nothing really helped me.. Does anyone have an idea please ?

Upvotes: 0

Views: 1301

Answers (1)

Tanmay Mishra
Tanmay Mishra

Reputation: 11

You can create the object of nested class like:

A.B obj = new A.B();

but your nested class should be static.

Upvotes: 1

Related Questions