Assertion in Java

Assertion facility is added in J2SE 1.4. In order toto false and assertions are enabled, AssertionError
support this facility J2SE 1.4 added the keywordwill be thrown at runtime.Some examples that use
assert to the language, and AssertionError class.simple assertion form are as follows.assert value
An assertion checks a boolean-typed expression> 5 ;assert accontBalance > 0;assert
that must be true during program runtimeisStatusEnabled();The expression that has to be
execution. The assertion facility can be enabled orasserted runtime must be boolean value. In third
disable at runtime. Declaring Assertion Assertionexample isStatusEnabled() must return boolean
statements have two forms as givenvalue. If condition evaluates to true, execution
belowassert expression;assert expression1 :continues normally, otherwise the AssertionError
expression2;The first form is simple form ofis thrown.Following program uses simple form of
assertion, while second form takes anotherassertion//AssertionDemo.javaClass
expression. In both of the form booleanAssertionDemo{Public static void main(String
expression represents condition that must beargs[]){System.out.println(
evaluate to true runtime.If the condition evaluateswithdrawMoney(1000,500) );System.out.