UP | HOME
../../

Assertions in Java

1 Java Programming With Assertions by Oracle.com

  1. Assertions are part of language definition. Not macro based.
  2. E1 is a boolean expressions. E2 is an expression that has a value.
  3. assert E1 ; When the system runs the assertion, it evaluates E1 and if it is false throws an AssertionError with no detail message.
  4. assert E1 : E2 ; The AssertionError constructor uses the string value of E2 to generate a detailed message when E1 is false.

2 Excerpts from http://www.javapractices.com/

  1. Assertions in general
  2. Assert use cases
  3. Force enabling of assertions
  4. Assert is for private arguments only

3 References

  1. Oracle.com, Java Programming With Assertions, https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html,
    1. Required Reading.
  1. http://www.javapractices.com/ Assertions Writeup Recommended Reading.
  2. "I am studing for … Oracla Java SE Certification and I saw this question …" http://stackoverflow.com/questions/15072956/ Recommended Reading.
  3. Lecture Notes of lehigh-edu. Recommended Reading.

4 End


Copyright © 2018 pmateti@wright.edu www.wright.edu/~pmateti 2018-06-12