mardi 12 février 2019

Use Reflection to get name of field

Say I have two classes:

class One{
  final Two xxx = new Two();

}

public class Two{

  public Two(){
    // is there a way to determine that this Two is a member of One?
    // looking to get the field name "xxx" here
  }
}

I am wondering if I can retrieve the fieldName using reflection from the Two constructor.





Aucun commentaire:

Enregistrer un commentaire