Returns a Class object identifying the declared type of this field.
Examples
package com.logicbig.example.field;
import java.lang.reflect.Field;
public class GetTypeExample { private int anInt;
public static void main(String... args) throws NoSuchFieldException { Field f = GetTypeExample.class.getDeclaredField("anInt"); Class<?> type = f.getType(); System.out.println(type);
} }
Output
int
package com.logicbig.example.field;
import java.lang.reflect.Field;
public class GetTypeExample2 { private int[] ints;
public static void main(String... args) throws NoSuchFieldException { Field f = GetTypeExample2.class.getDeclaredField("ints"); Class<?> v = f.getType(); System.out.println(v); String name = v.getTypeName(); System.out.println(name); } }