Possible Duplicate:
Get generic type of java.util.List
How can I see what type is within a list in a parameter
private List<String> names;
how would I be able to find out that its a list of Strings? My goal is to make a method like this working:
public Field findFieldByObjectType(Class<?> clazz, Object obj) {
for (Field field : clazz.getDeclaredFields()) {
// if field type is List<obj>
// return field
}
}