Online Java Compiler By
JavaTpoint.com
import java.lang.reflect.*; public class ClassgetDeclaredFieldExample1 { public static void main(String[] args) { try { ClassgetDeclaredFieldExample1 obj = new ClassgetDeclaredFieldExample1(); Class cls = obj.getClass(); Field fval = cls.getDeclaredField("lng"); System.out.println("Field = " + fval.toString()); } catch(Exception e) { System.out.println(e.toString()); } } public ClassgetDeclaredFieldExample1() { } public ClassgetDeclaredFieldExample1(long lng) { this.lng = lng; } long lng = 5555; }
Output