一、程序中 + 号的使用
- 当左右两边都是数值型是.则做加法运算
- 当左右两边有一方为字符串,则做拼接运算
-
运算顺序: 从左到右
public class MathThinking{ public static void main(String[] args){ System.out.println(100 + 98); //198 System.out.println("100" + 98); //10098 System.out.println(100 + 3 + "hello"); //103hello System.out.println("hello" + 100 + 3); // hello1003 } }