lundi 25 mars 2019

How to get a instance variable name from this instance in Java

Is there a way to to do something like this?

public class T {
    String var = "Some value";

    public void show() {
        System.out.println(var.getClass().getName()); // Prints var
    }
}





Aucun commentaire:

Enregistrer un commentaire