字串連線符 +
阿新 • • 發佈:2021-01-25
10+20=30;
" “+10+20=1020;
10+20+” "=30;
public class demo5 {
public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println(a+b);
//字串連線符 +
System.out.println(""+a+b);
System.out.println(a+b+"");
}
}
當" “在數字運算的前邊時,後邊的數字運算會按照字串的形式相加
當” "在數字的末尾時,輸出結果雖然仍是字串型,但輸出的是a+b的運算結果
執行結果: