Learn Java Programming - Assertions Part Two Tutorial (assert keyword)

Published: 19 January 2016
on channel: Daniel Ross
1,636
21

After watching my Assertions Part 1 Tutorial you should have a general idea of what an assertion is used for. In part 1 I demonstrated one of two styles of the assert statement.
assert (expression) : argument to pass into the AssertionError constructor ;
The second style is even more simple:
assert (expression) ;
The second style will simply throw an AssertionError if the expression evaluates to false. You will receive the same sort of program stopping crash that you experience with the first style, only it will simply contain the method and line number of the assert statement. There is not much of a difference between the two versions, just a little more debugging info in the first style.


On this page of the site you can watch the video online Learn Java Programming - Assertions Part Two Tutorial (assert keyword) with a duration of hours minute second in good quality, which was uploaded by the user Daniel Ross 19 January 2016, share the link with friends and acquaintances, this video has already been watched 1,636 times on youtube and it was liked by 21 viewers. Enjoy your viewing!