All pastes #173613 Raw Edit

Anonymous

public java v1 · immutable
·published 2006-09-17 03:35 UTC
rendered paste body
import java.lang.reflect.Field;public class AccessibilityTest {    public static void main(String[] args) throws Exception {        // Initlaize new Test object        Test testObject = new Test();                // Obtain the Class object of the Test class        Class<?> testClass = test.getClass();                // Get the testInt Field value and set it as accessible        Field testIntField = testClass.getDeclaredField("testInt");        testIntField.setAccessible(true);                // Obtain the testInt value        int testIntValue = testInt.get(testObject));    }        private static class Test {        private int testInt = 25;    }}