jeudi 4 mars 2021

Reflection To check if field exist in containing class [duplicate]

class A{
   String name;
   B b;
}

class B{
   String text;
}

Now if I do A.class.getField("text"); This will give exception. How can I use reflection to see if field exist in Containing class B

If its a direct field in Class A reflection works. But if the field is within another containing Class Object(In this case class B) it wont retrieve the field





Aucun commentaire:

Enregistrer un commentaire