A Program to Check Whether Assertion is Enabled - Java Language Basics

Java examples for Language Basics:assert

Description

A Program to Check Whether Assertion is Enabled

Demo Code

public class Main {
  public static void main(String[] args)  {
    boolean enabled = false;
    assert enabled = true;
    if (enabled) {
      System.out.println("Assertion is enabled.");
    }/*from   ww  w. jav  a 2  s  . co m*/
    else {
      System.out.println("Assertion is disabled.");
    }
  }
}

Result


Related Tutorials