Code example for Field

Methods: getInt, isAccessible, setAccessible

0
    public Field getField() {
	return field;
    } 
 
    public void printObject(DataClass data) {
	if(!field.isAccessible()) {
	    field.setAccessible(true);
	    System.err.println("field.accessible: " + field.isAccessible());
	} 
	try { 
	    System.out.println("accessed: " + field.getInt(data));
	} 
	catch(Exception ex) {
	    ex.printStackTrace();
	} 
	// forgot to reset to non-accessible 
	System.err.println("field.accessible: " + field.isAccessible());
    } 
 
}