Assert with an informative message : Assert « Language Basics « Java






Assert with an informative message

  

//: c15:Assert2.java
// {JVMArgs: -ea}
// {ThrowsException}
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

public class Assert2 {
  public static void main(String[] args) {
    assert false: "Here's a message saying what happened";
  }
}

           
         
    
  








Related examples in the same category

1.A Program with Assertions
2.Enabling Assertions from the Command Line: -ea and -da enable and disable assertion in a package subtree or in a class.
3.Handling an Assertion Error
4.Catch assert exception with message
5.Non-informative style of assert
6.Using the class loader to enable assertions
7.Class for checking syntax and comments for the assert
8.Assert Util
9.Assertion utility class that assists in validating arguments.
10.An assertion utility just for simple checks.