Code example for Field

Methods: getInt, setInt

0
            fail("Accessed field of invalid type");
        } catch (IllegalArgumentException ex) {
            thrown = true;
        } 
        assertTrue("IllegalArgumentException expected but not thrown", thrown);
         
        //test not accessible 
        thrown = false;
        try { 
            f = x.getClass().getDeclaredField("charPFField");
            assertFalse(f.isAccessible());
            f.setChar(x, Character.MIN_VALUE);
            fail("Accessed inaccessible field");
        } catch (IllegalAccessException ex) {
            thrown = true;
        } 
        assertTrue("IllegalAccessException expected but not thrown", thrown);
         
      //Test NPE 
        thrown = false;
        try {