What does the Java assert keyword do, and when should it be used?

前端 未结 19 1726
眼角桃花
眼角桃花 2020-11-22 15:58

What are some real life examples to understand the key role of assertions?

19条回答
  •  感情败类
    2020-11-22 16:32

    assert is a keyword. It was introduced in JDK 1.4. The are two types of asserts

    1. Very simple assert statements
    2. Simple assert statements.

    By default all assert statements will not be executed. If an assert statement receives false, then it will automatically raise an assertion error.

提交回复
热议问题