Java examples for Reflection:Field
print Fields
//package com.java2s; import java.lang.reflect.*; import static java.lang.System.out; public class Main { public static void printFields(Class<?> c) { Field[] fields = c.getFields(); out.format("Fields => %n"); if (fields.length == 0) { out.format(" --%s", "No declared field found"); } else {//from ww w. j av a 2 s . c om for (Field f : fields) { out.format(" %s %s %s%n", Modifier.toString(f .getModifiers()), f.getType().getCanonicalName(), f .getName()); } } out.format("%n%n"); } }