This is my code
class Foo {
public static String init() {
//return "A" for Bar.A
//return "B" for Bar.B
}
}
class Bar {
public final static String A = Foo.init();
public final static String B = Foo.init();
}
In Foo.init() I want to know what field will be initialized (in B,C,D class) and return value according to the field. Is it possible to do using reflection? If yes, then how? Please note, the question is about reflection, but not about Foo.init("A")
.
Aucun commentaire:
Enregistrer un commentaire