Last active
January 2, 2016 11:09
-
-
Save pato/8294889 to your computer and use it in GitHub Desktop.
Example of getting variable names in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
public class name { | |
public int myint = 5; | |
public Integer myInteger = new Integer(44); | |
public String pato = "Lankenau"; | |
public boolean mybool = false; | |
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException { | |
name t = new name(); | |
for(Field f : t.getClass().getFields()) { | |
System.out.println(f.getGenericType() +" "+f.getName() + " = " + f.get(t)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment