幫助下 看下我輸出的代碼
public class HelloWorld{
? ? public static void main(String[] args) {
? ? ? ?final char NAME='男';
? final char LOVE='女';
System.out.println(NAME+LOVE);
}
}
public class HelloWorld{
? ? public static void main(String[] args) {
? ? ? ?final char NAME='男';
? final char LOVE='女';
System.out.println(NAME+LOVE);
}
}
2016-03-22
舉報
2016-03-23
""是空字符串,基本數(shù)據(jù)類型 + 字符串類型 ? ?系統(tǒng)會自動轉(zhuǎn)換成字符串類型的連接,即輸出“男女”。
2016-03-22
System.out.println(NAME + LOVE); ? ?
系統(tǒng)輸出:52906
因為char是基本數(shù)據(jù)類型,會自動做加法運算,如果要輸出字符串,可以這樣寫:
System.out.println(NAME ?+ "" + LOVE);
2016-03-22
52906
NAME和LOVE換成String類型會輸出男女
2016-03-22
不知道
2016-03-22
public class HelloWorld{
? ? public static void main(String[] args) {
? ? ? ?final String NAME="男";
? ? ? ?final String LOVE="女";
? ? ? ?System.out.println(NAME);
? ? ? ? System.out.println(LOVE);
? ? }
}