Here you can find the source of getFields(Class> cs)
public static Field[] getFields(Class<?> cs)
//package com.java2s; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; public class Main { public static Field[] getFields(Class<?> cs) { List<Field> fieldList = new ArrayList<Field>(); Class<?> c = cs;//from ww w . ja v a 2s. com while (c != null) { Field[] fields = c.getDeclaredFields(); for (Field field : fields) { fieldList.add(field); } c = c.getSuperclass(); } return fieldList.toArray(new Field[fieldList.size()]); } }