Skip to Content
0
Former Member
Jul 26, 2005 at 01:22 PM

Assert statement

33 Views

Hi,

i am developing on jdk 1.4.2_8 and use assert statements to ensure that e.g. references are not null:

Object test = null;

try {

assert test != null;

test.doSomething();

} catch (AssertionError error) {

//do something

}

The problem is that the assert - which is highlighted as keyword in NWDI - does not throw an exception but goes on and the test.doSomething() throws a null-Pointer.

Do you have any clue why the assert does not work properly?

Thank you and best regards,

Daniel