Advertisement
Guest User

Untitled

a guest
Apr 17th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. package doAnalysis;
  2.  
  3. import java.lang.reflect.Field;
  4. import java.lang.reflect.Modifier;
  5.  
  6.  
  7. public class FieldAccessible {
  8.     public static class MyClass {
  9.         private String theField;
  10.     }
  11.     public static void main(String[] args) throws Exception {
  12.         MyClass myClass = new MyClass();
  13.         Field field1 = myClass.getClass().getDeclaredField("theField");
  14.         field1.setAccessible(true);
  15.         System.out.println(field1.get(myClass));
  16.     }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement