Field.getDouble(Object obj) has the following syntax.
public double getDouble(Object obj) throws IllegalArgumentException , IllegalAccessException
In the following code shows how to use Field.getDouble(Object obj) method.
// w ww.j a va 2 s. com import java.lang.reflect.Field; class MyClass { public double i = 1.123; } public class Main { public static void main(String[] args) throws Exception { Class<?> clazz = Class.forName("MyClass"); MyClass x = (MyClass) clazz.newInstance(); Field f = clazz.getField("i"); System.out.println(f.getDouble(x)); f.setDouble(x, 9.99); System.out.println(f.getDouble(x)); } }
The code above generates the following result.