vendredi 3 avril 2020

How to get class in the field value using reflection?

Consider the following code

class Foo {

}

class Bar {
    private Foo foo = new Foo();
}

Is it possible in Foo class to get the class of foo field. I mean, I want in Foo to get Bar class. The question is of course about reflection, but not about new Foo(Bar.class).





Aucun commentaire:

Enregistrer un commentaire