A field may be
The class Field has two methods to know its type:
public Class<?> getType() public Type getGenericType()
The following program shows all field names and their types of given class:
import java.lang.reflect.Field; public class Main { public static void main(String args[]) throws Exception { Class c = Class.forName("java.lang.String"); Field[] fields = c.getDeclaredFields(); for (Field f : fields) System.out.println(f.getType() + " " + f.getName()); }/*from ww w. j ava2 s .c o m*/ }