Java tutorial
//package com.java2s; //License from project: Open Source License import java.lang.reflect.*; import java.util.*; public class Main { /** * Returns all the unique fields of the classes in the given list. * @author Tristan Bepler */ private static Field[] getAllFields(List<Class<?>> classes) { Set<Field> fields = new HashSet<Field>(); for (Class<?> clazz : classes) { fields.addAll(Arrays.asList(clazz.getDeclaredFields())); } return fields.toArray(new Field[fields.size()]); } }