I am getting compilation error in Line 3, Is it any special case for asserts in java ? i am not sure why it’s expecting some return type from methodB() , can somebody help me here ? Thanks
public class AssertTest {
public void methodA(int i) {
assert i >= 0 : methodB();
System.out.println(i);
}
public void methodB() {
System.out.println("The value must not be negative");
}
public static void main(String args[]) {
AssertTest test = new AssertTest();
test.methodA(-10);
}
}
http://download.oracle.com/javase/1.4.2/docs/guide/lang/assert.html
Basically,
Expression2must return a value, notvoid.