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.
На этой странице сайта вы можете посмотреть видео онлайн Learn Java Programming - Assertions Part Two Tutorial (assert keyword) длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Daniel Ross 19 Январь 2016, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,636 раз и оно понравилось 21 зрителям. Приятного просмотра!