Java tutorial
//package com.java2s; import java.lang.reflect.Field; import java.util.List; public class Main { private static void addFields(Class<?> clazz, List<Field> list) { for (Field f : clazz.getFields()) { list.add(f); } Class<?> superClass = clazz.getSuperclass(); if (superClass != null) { addFields(superClass, list); } } }