锘??xml version="1.0" encoding="utf-8" standalone="yes"?>中文.日本.精品,精品成人自拍视频,国产偷国产偷亚洲高清97caohttp://www.aygfsteel.com/dhc/category/37032.htmlzh-cnMon, 29 Dec 2008 17:37:41 GMTMon, 29 Dec 2008 17:37:41 GMT60鍚嶈瘝瑙i噴涔媋ssert銆愯漿杞姐?/title><link>http://www.aygfsteel.com/dhc/articles/249032.html</link><dc:creator>DHC</dc:creator><author>DHC</author><pubDate>Mon, 29 Dec 2008 16:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/dhc/articles/249032.html</guid><wfw:comment>http://www.aygfsteel.com/dhc/comments/249032.html</wfw:comment><comments>http://www.aygfsteel.com/dhc/articles/249032.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dhc/comments/commentRss/249032.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dhc/services/trackbacks/249032.html</trackback:ping><description><![CDATA[<div>java assert鐨勭敤娉?/div> <div> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><font size="2">assert <span style="font-family: 瀹嬩綋">鏄湪</span> J2SE1.4 <span style="font-family: 瀹嬩綋">涓紩鍏ョ殑鏂扮壒鎬э紝</span> assertion <span style="font-family: 瀹嬩綋">灝辨槸鍦ㄤ唬鐮佷腑鍖呮嫭鐨勫竷灝斿瀷鐘舵侊紝紼嬪簭鍛樿涓鴻繖涓姸鎬佹槸</span> true <span style="font-family: 瀹嬩綋">銆備竴鑸潵璇?/span> assert <span style="font-family: 瀹嬩綋">鍦ㄥ紑鍙戠殑鏃跺欐槸媯鏌ョ▼搴忕殑瀹夊叏鎬х殑錛屽湪鍙戝竷鐨勬椂鍊欓氬父閮戒笉浣跨敤</span> assert <span style="font-family: 瀹嬩綋">銆傚湪</span> 1.4 <span style="font-family: 瀹嬩綋">涓坊鍔犱簡</span> assert <span style="font-family: 瀹嬩綋">鍏抽敭瀛楀拰</span> java.lang.AssertError <span style="font-family: 瀹嬩綋">綾葷殑鏀寔銆?/span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">      <span style="font-family: 瀹嬩綋">棣栧厛錛屾垜浠湁蹇呰浠庝竴涓緥瀛愯璧?/span> assert </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">public class AssertTest</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">{</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> public static void main(String[] args)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> AssertTest at = new AssertTest();</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> at.assertMe(true);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> at.assertMe(false);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> } </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> private void assertMe(boolean boo)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> assert boo?true:false; </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> System.out.println(true condition);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">}</font> </p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><font size="2"><span style="font-family: 瀹嬩綋">紼嬪簭涓寘鍚簡</span> assert <span style="font-family: 瀹嬩綋">鐨勮瘽錛屼綘瑕佺敤</span> javac -source 1.4 xxx.java <span style="font-family: 瀹嬩綋">鏉ョ紪璇戯紝鍚﹀垯緙栬瘧鍣ㄤ細鎶ラ敊鐨勩傝鎯寵</span> assert <span style="font-family: 瀹嬩綋">寰楅儴鍒嗚繍琛岀殑璇濓紝瑕佷嬌鐢?/span> java -ea xxx <span style="font-family: 瀹嬩綋">鏉ヨ繍琛岋紝鍚﹀垯鍖呭惈</span> assert <span style="font-family: 瀹嬩綋">寰楄浼氳蹇界暐銆備笅闈㈡垜浠繍琛?/span> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="background: yellow; color: red"><font size="2">javac -source 1.4 AssertTest.java </font></span></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="background: yellow; color: red">java -ea AssertTest</span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="font-family: 瀹嬩綋">鐪嬬湅緇撴灉鐨勮緭鍑烘槸錛?/span> </font></p> <p style="margin: 0cm 0cm 0pt"><span style="background: yellow; color: red"><font size="2">true condition</font> </span></p> <p style="margin: 0cm 0cm 0pt"><span style="background: yellow; color: red"><font size="2">Exception in thread main java.lang.AssertionError</font> </span></p> <p style="margin: 0cm 0cm 0pt"><span style="background: yellow; color: red"><font size="2">        at AssertTest.assertMe(AssertTest.java:13)</font> </span></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="background: yellow; color: red">        at AssertTest.main(AssertTest.java:7)</span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="font-family: 瀹嬩綋">褰撴垜浠繍琛?/span> at.assertMe(true) <span style="font-family: 瀹嬩綋">寰楁椂鍊欙紝鐢變簬</span> assert boo?true:false <span style="font-family: 瀹嬩綋">鐩稿綋浜?/span> assert true; <span style="font-family: 瀹嬩綋">鍥犳娌℃湁浠諱綍闂錛岀▼搴忓線涓嬫墽琛屾墦鍗板嚭</span> true condition <span style="font-family: 瀹嬩綋">錛屼絾鏄墽琛?/span> at.assertMe(false) <span style="font-family: 瀹嬩綋">鐨勬椂鍊欑浉褰撲簬</span> assert false <span style="font-family: 瀹嬩綋">錛岃繖涓椂鍊欒В閲婂櫒灝變細鎶涘嚭</span> AssertionError <span style="font-family: 瀹嬩綋">浜嗭紝紼嬪簭灝辯粓姝簡銆傚ぇ瀹跺繀欏繪竻妤?/span> AssertionError <span style="font-family: 瀹嬩綋">鏄戶鎵胯嚜</span> Error <span style="font-family: 瀹嬩綋">寰楋紝鍥犳浣犲彲浠ヤ笉鍐嶇▼搴忎腑</span> catch <span style="font-family: 瀹嬩綋">瀹冪殑錛屽綋鐒朵綘涔熷彲浠ュ湪紼嬪簭涓?/span> catch <span style="font-family: 瀹嬩綋">瀹冪劧鍚庣▼搴忓彲浠ョ戶緇墽琛屻備緥濡傦細</span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">public class AssertTest</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">{</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> public static void main(String[] args)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> AssertTest at = new AssertTest();</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> try</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   at.assertMe(true);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   at.assertMe(false);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> catch(AssertionError ae)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   System.out.println(AsseriontError catched); </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> System.out.println(go on);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> } </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> private void assertMe(boolean boo)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> assert boo?true:false; </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> System.out.println(true condition);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">}</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">    assert <span style="font-family: 瀹嬩綋">榪樻湁鍙﹀涓縐嶈〃杈劇殑鏂瑰紡錛屽氨鏄?/span> assert exp1:exp2; <span style="font-family: 瀹嬩綋">鍏朵腑</span> exp1 <span style="font-family: 瀹嬩綋">鏄釜</span> boolean <span style="font-family: 瀹嬩綋">榪斿洖鍊煎緱琛ㄨ揪寮忥紝鑰?/span> exp2 <span style="font-family: 瀹嬩綋">鍙互鏄師濮嬬殑鏁版嵁綾誨瀷鎴栬呭璞¢兘鍙互渚嬪錛?/span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">   boolean boo = true;</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   String str = null;</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">    assert boo = false <span style="font-family: 瀹嬩綋">錛?/span> str=error; </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="font-family: 瀹嬩綋">鎴戜滑鍒氬紑濮嬭寰?/span> assert exp1 <span style="font-family: 瀹嬩綋">寰楀艦寮忥紝褰?/span> exp1 <span style="font-family: 瀹嬩綋">鏄?/span> false <span style="font-family: 瀹嬩綋">寰楁椂鍊欙紝</span> AssertionError <span style="font-family: 瀹嬩綋">寰楅粯璁ゆ瀯閫犲櫒浼氳璋冪敤錛屼絾鏄?/span> assert exp1:exp2 <span style="font-family: 瀹嬩綋">榪欐牱鐨勫艦寮忥紝褰?/span> exp1 <span style="font-family: 瀹嬩綋">涓?/span> true <span style="font-family: 瀹嬩綋">鐨勬椂鍊欏悗闈?/span> exp2 <span style="font-family: 瀹嬩綋">琚垨鐣ワ紝濡傛灉</span> false <span style="font-family: 瀹嬩綋">鐨勮瘽錛屽悗闈㈢殑琛ㄨ揪寮忕殑緇撴灉浼氳璁$畻鍑烘潵騫朵綔涓?/span> AssertionError <span style="font-family: 瀹嬩綋">寰楁瀯閫犲櫒鍙傛暟銆傜湅涓嬮潰鐨勪緥瀛愶細</span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">public class AssertTest</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">{</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> public static void main(String[] args)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> AssertTest at = new AssertTest();</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> at.assertMe(true);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> at.assertMe(false);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> } </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> private void assertMe(boolean boo)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> String s = null;</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> assert boo?true:false:s = hello world; </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"> System.out.println(true condition);</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"> }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">  </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">} <span style="font-family: 瀹嬩綋">榪愯鐨勬椂鍊欎細寰楀埌榪欐牱鐨勭粨鏋?/span> </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">true condition</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">Exception in thread main java.lang.AssertionError: hello world</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">        at AssertTest.assertMe(AssertTest.java:14)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">        at AssertTest.main(AssertTest.java:7)</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">Assert <span style="font-family: 瀹嬩綋">鏈濂戒笉瑕佹互鐢紝鍘熷洜鏄?/span> assert <span style="font-family: 瀹嬩綋">騫朵笉涓瀹氶兘鏄?/span> enable <span style="font-family: 瀹嬩綋">鐨勶紝涓嬮潰涓ょ鎯呭喌灝變笉搴旇鐢?/span> assert </font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><font size="2"><font style="background-color: #ffff33">1 <span style="font-family: 瀹嬩綋">涓嶈鍐?/span> public <span style="font-family: 瀹嬩綋">鐨勬柟娉曢噷闈㈡鏌ュ弬鏁版槸涓嶆槸涓?/span> null <span style="font-family: 瀹嬩綋">涔嬬被鐨勬搷浣?/span> </font></font></p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="font-family: 瀹嬩綋">渚嬪</span> public int get(String s) </font></p> <p style="margin: 0cm 0cm 0pt"><font size="2">   {</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">       assert s != null;</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">   }</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2"><span style="font-family: 瀹嬩綋">濡傛灉闇瑕佹鏌ヤ篃鏈濂介氳繃</span> if s = null <span style="font-family: 瀹嬩綋">鎶涘嚭</span> NullPointerException <span style="font-family: 瀹嬩綋">鏉ユ鏌?/span> </font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><font size="2"><font style="background-color: #ffff33">2 <span style="font-family: 瀹嬩綋">涓嶈鐢?/span> assert <span style="font-family: 瀹嬩綋">鏉ユ鏌ユ柟娉曟搷浣滅殑榪斿洖鍊兼潵鍒ゆ柇鏂規硶鎿嶄綔鐨勭粨鏋?/span> </font>   </font></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><font size="2"><span style="font-family: 瀹嬩綋">渚嬪</span> assert list.removeAll(); <span style="font-family: 瀹嬩綋">榪欐牱鐪嬭搗鏉ュソ鍍忔病鏈夐棶棰?/span> <span style="font-family: 瀹嬩綋">浣嗘槸鎯蟲兂濡傛灉</span> assert <span style="font-family: 瀹嬩綋">琚?/span> disable <span style="font-family: 瀹嬩綋">鍛紝閭f牱浠栧氨涓嶄細琚墽琛屼簡</span> <span style="font-family: 瀹嬩綋">鎵浠?/span> removeAll() <span style="font-family: 瀹嬩綋">鎿嶄綔灝辨病鏈夎鎵ц</span>  <span style="font-family: 瀹嬩綋">鍙互榪欐牱浠f浛<br /> </span></font><font size="2">boolean boo = list.removeAl();</font> </p> <p style="margin: 0cm 0cm 0pt"><font size="2">assert boo;</font> </p> </div> <img src ="http://www.aygfsteel.com/dhc/aggbug/249032.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dhc/" target="_blank">DHC</a> 2008-12-30 00:04 <a href="http://www.aygfsteel.com/dhc/articles/249032.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> 主站蜘蛛池模板: <a href="http://" target="_blank">岳阳市</a>| <a href="http://" target="_blank">增城市</a>| <a href="http://" target="_blank">巫山县</a>| <a href="http://" target="_blank">怀宁县</a>| <a href="http://" target="_blank">景德镇市</a>| <a href="http://" target="_blank">攀枝花市</a>| <a href="http://" target="_blank">元氏县</a>| <a href="http://" target="_blank">卢龙县</a>| <a href="http://" target="_blank">滨海县</a>| <a href="http://" target="_blank">唐河县</a>| <a href="http://" target="_blank">离岛区</a>| <a href="http://" target="_blank">广昌县</a>| <a href="http://" target="_blank">芦山县</a>| <a href="http://" target="_blank">皮山县</a>| <a href="http://" target="_blank">竹北市</a>| <a href="http://" target="_blank">盘锦市</a>| <a href="http://" target="_blank">维西</a>| <a href="http://" target="_blank">枝江市</a>| <a href="http://" target="_blank">乡城县</a>| <a href="http://" target="_blank">黔西县</a>| <a href="http://" target="_blank">衡东县</a>| <a href="http://" target="_blank">怀远县</a>| <a href="http://" target="_blank">东港市</a>| <a href="http://" target="_blank">都安</a>| <a href="http://" target="_blank">西乡县</a>| <a href="http://" target="_blank">灵宝市</a>| <a href="http://" target="_blank">玉田县</a>| <a href="http://" target="_blank">武汉市</a>| <a href="http://" target="_blank">台州市</a>| <a href="http://" target="_blank">木里</a>| <a href="http://" target="_blank">澄城县</a>| <a href="http://" target="_blank">泉州市</a>| <a href="http://" target="_blank">肃南</a>| <a href="http://" target="_blank">泰顺县</a>| <a href="http://" target="_blank">梁河县</a>| <a href="http://" target="_blank">文化</a>| <a href="http://" target="_blank">阳谷县</a>| <a href="http://" target="_blank">安宁市</a>| <a href="http://" target="_blank">灌南县</a>| <a href="http://" target="_blank">汉源县</a>| <a href="http://" target="_blank">望谟县</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>