assert Expression1;
assert Expression1:Expression2;
Expression1 must have boolean type.
Expression2 may have any type.
If Expression1's value is true, no further action is taken.
If Expression1's value is false, then an AssertionError is thrown.
If Expression2 is present, it is converted to a String and used as the error's message.
public class MainClass {
public static void main(String[] argv) {
String title = null;
assert isValidTitle();
System.out.println();
}
static boolean isValidTitle() {
return false;
}
}
|