Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.lang.reflect.*;
  2.  
  3. public class field2 {
  4.     public double d;
  5.  
  6.     public static void main(String args[]) {
  7.         try {
  8.             Class cls = Class.forName("field2");
  9.             Field fld = cls.getField("d");
  10.             field2 f2obj = new field2();
  11.             System.out.println("d = " + f2obj.d);
  12.             fld.setDouble(f2obj, 12.34);
  13.             System.out.println("d = " + f2obj.d);
  14.         } catch (Throwable e) {
  15.             System.err.println(e);
  16.         }
  17.     }
  18. }