Java tutorial
import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class Main { public static void main(String[] args) { Field[] fields = java.lang.Integer.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field f = fields[i]; Class type = f.getType(); String name = f.getName(); System.out.print(Modifier.toString(f.getModifiers())); System.out.println(" " + type.getCanonicalName() + " " + name + ";"); } } }