Math类和字符串连接符"+"
幂运算
Math类
public class Demo04 {
public static void main(String[] args) {
//幂运算 2^3 2*2*2 = 8
double pow = Math.pow(2,3);
System.out.println(pow);
}
}
字符串连接符 +,String
两者区别
public class Demo07 {
public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println(""+a+b);
//1020
System.out.println(a+b+"");
//30
}
}
浙公网安备 33010602011771号