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;
}
}