All pastes #190426 Raw Edit

Someone

public text v1 · immutable
·published 2006-10-03 23:38 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;
    }
}