public class AssertTest {
public void methodA(int i) {
assert i >= 0 : methodB();
System.out.println(i);
}
public String methodB() { // 无返回值
System.out.println("The value must not be negative");
return "The value must be negative!";
}
public static void main(String args[]) {
AssertTest test = new AssertTest();
test.methodA(-10);
}
}