朋友們幫我解答呀 為什么會拋異常呢 著急?。?!
package?com.imooc;public?class?X?{ public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub?? ?String?a="是";? ???String?a1="否";??? ???int?b=Integer.valueOf(a); ??? int?b1=Integer.valueOf(a1); ?? ??? if(b==b1){ ?? ??? ?System.out.println("錯"); ??? ? ???}else{ ?? ??? ? ????System.out.println("對"); ??? ? ???????} ??? ? ???????}}
2018-08-28
Integer.valueOf(a)是根據(jù)字符串來轉(zhuǎn)化成Intrger類型的,你的字符串是漢字,肯定是轉(zhuǎn)不了的。