???????????
??????C??C++?????ж???assert?????????????
??????Java?У???????assert???????????????÷?????嶼????
??????????
??????Java?У?assert????????JAVA SE 1.4 ???????????????汾??Java???????????assert???????′???Java????е??????????????????????????????е??????????????????????????????飬??????????-enableassertions??-ea???????
????assert???????????????????÷???
????1??assert <boolean????>
???????<boolean????>?true??????????????С?
????????false??????????AssertionError?????????С?
????2??assert <boolean????> : <???????????>
???????<boolean????>?true????????????С?
????????false??????????java.lang.AssertionError????????<???????????>??
??????????????
????????????????????????????????÷???
????public class AssertFoo {
????public static void main(String args[]) {
????//????1????true??????????????
????assert true;
????System.out.println("????1???????Go??");
????System.out.println(" ----------------- ");
????//????2????false?????????
????assert false : "???????????????????????????????????????";
????System.out.println("????2???????Go??");
????}
????}
???????????C:AssertFoo.java????????????????У????????????????
????1?????????
????C:>javac AssertFoo.java
????2???????г?????п???-ea?????
????C:>java AssertFoo
????????1???????Go??
????-----------------
????????2???????Go??
????3??????-ea???????г???
????C:>java -ea AssertFoo
????????1???????Go??
????-----------------
????Exception in thread "main" java.lang.AssertionError: ????????????????????
???????????????????????
????at AssertFoo.main(AssertFoo.java:10)
???????????
????assert??????÷????????????assert??????????????????????????С????????á?????????о???????????????
????1??assert?????????????????????????????Ч????????????????κ????塣????????????Java IDE??????????п???-ea?????鸚???????ζ??????????IDE???????????????????????????鷳???????????Java Web?????????????????????????棬????????????????????У????????????-ea???????????????Web?????????????ò???????????????????????????????
????2????assert????if???????????assert???ж??if?????????????????????????????assert????????????????????????????????????С????assert??????????????????????????????????????assert???????ζ??????????????????????
????3??assert?????????????????????????????????????μ????????????????????????????????????????????????????????????Σ????????????????
?????塢??assert?????
????assert???????????????????????????????????????????????????????JUint?????????????JUint???assert?????????????????й????????????????????????IDE debug?????е???????????????assert???????譫??
?????????????????Java?????assert????????????Java?????????-ea???????????????????????£?assert?????????????????????鷳????????????????????????