Java tutorial
//package com.java2s; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; public class Main { private static List<Field> getAllFieads(Object o) { ArrayList<Field> fields = new ArrayList<Field>(); if (o != null) { Class<?> type = o.getClass(); do { for (Field f : type.getDeclaredFields()) { fields.add(f); } type = type.getSuperclass(); } while (type != null); } return fields; } }