最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

System.out.println(SEX1+SEX2)錯(cuò)在哪里

final char SEX1 = '男'; final char SEX2 = '女'; ? ? ? ?/*下面這種是錯(cuò)誤的 ?????? ? ? ? ?//正確的是 ? ? ? ?System.out.println(SEX1); ? ? ? ?System.out.println(SEX2); ? ? ? ?//或者 ? ? ? ?System.out.printf("%c,%C",SEX1,SEX2); 為什么上面這種寫(xiě)法就是錯(cuò)誤的呢

正在回答

3 回答

public class HelloWorld{
? ?public static void main(String[] args) {

//char 表示的是 0-65535的數(shù)字?

? ?final char SEX1 = '男';

? ?final char SEX2 = '女';

? ? ? ?System.out.println((int)SEX1);//30007
? ? ? ?System.out.println((int)SEX2);//22899
? ? ? ?System.out.println(SEX1+SEX2);//52906 = 30007+22899
? ? ? ?//因?yàn)閖ava中, String類(lèi)型的+ ?表示連接 . char byte int long等的四則運(yùn)算都是一樣的

? ? ? ?System.out.println(SEX1);
? ? ? ?System.out.println(SEX2);
? ? ? ?System.out.println(""+SEX1+SEX2);//利用String的加法連接字符串,返回結(jié)果還是String ,進(jìn)行輸出 ? ?


0 回復(fù) 有任何疑惑可以回復(fù)我~

為什么字符類(lèi)型的常量不可以在輸出的時(shí)候使用System.out.println(SEX1+SEX2);這種來(lái)輸出。這樣寫(xiě)會(huì)輸出一串?dāng)?shù)字

0 回復(fù) 有任何疑惑可以回復(fù)我~

final char SEX1 = '男'; final char SEX2 = '女'; ? ? ? ?/*下面這種是錯(cuò)誤的 ?*/ ? ? ? ? ? ? //正確的是 ? ? ? ?System.out.println(SEX1); ? ? ? ?System.out.println(SEX2); ? ? ? ?//或者 ? ? ? ?System.out.printf("%c,%C",SEX1,SEX2);?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

System.out.println(SEX1+SEX2)錯(cuò)在哪里

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)