Difference between Java ‘assert’ and ‘if() {} else exit;’
•
Java
What is the difference between Java assert and if () {} exit;?
Can I use if () {} else to exit instead of asserting?
Solution
Is it possible?
"The main thing you should remember is that if else statements should be used for program flow control, and the assert keyword should only be used for testing purposes. You should never use assertions to actually perform any operation required by your application. Work well. According to sun's official JAVA document:" each assertion contains a Boolean expression, and you think it will be true when the assertion is executed. " “
Read more: http://wiki.answers.com/Q/What_is_the_difference_between_assert_keyword_and_if_keyword_in_java#ixzz1v2GGfAhq
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码