为了在Java中编译assert,我们只需将布尔表达式设置为false。
让我们看一个示例程序-
public class Example {
public static void main(String[] args) {
assert false;
System.out.println("Compiled and executed successfully!!!");
}
}输出结果
Compiled and executed successfully!!!