java'assert'和'if(){} else之间的区别退出;' [英] Difference between java ' assert 'and ' if () {} else exit;'
问题描述
java assert
和之间的区别是if(){} else退出;
?
我可以使用 if(){} else exit
而不是断言
?
谷歌有点像?
你应该记住的主要事情是if-else语句应该用于程序流控制,而assert关键字只能用于测试目的。您永远不应该使用asserts来实际执行应用程序正常工作所需的任何操作。
根据Sun的官方Java文档:每个断言都包含一个布尔表达式,您认为在断言执行时它将是真的。 / p>
what is the difference between java assert
and if () {} else exit;
?
can i just use if () {} else exit
instead of assert
?
A bit of google maybe ?
" The main thing you should keep in mind is that the if-else statement should be used for program flow control and the assert keyword should only be used for testing purposes. You should never use asserts to actually perform any operation required for your application to work properly. According to Sun's official Java documentation: "Each assertion contains a boolean expression that you believe will be true when the assertion executes." "
这篇关于java'assert'和'if(){} else之间的区别退出;'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!