package com.j2se;
public class WarmingTest {
public static void main(String[] args) {
// 对于错将=写为==的情况,则该表达式为等号右边的值
String str1 = new String("AB");
String str2 = new String("ABC");
str1 = str1 + 4;
// 输出AB4
System.out.println(str1);
// 输出str2即"ABC"
System.out.println(str1 = str2);
// 编译可以通过,但运行会出现java.lang.NullPointerException异常
// int型数组中的数据初始化为0
int[] i1 = new int[10];
System.out.println(i1[0]);
// boolean型数组中的数据初始化为false
boolean[] b = new boolean[5];
System.out.println(b[0]);
// 对象型数组中的数据初始化为null
String[] strs = new String[5];
System.out.println(strs[1]);
// 传递给方法的参数在方法中的改变不会影响该参数
Integer ing = new Integer(0);
function(ing);
// 输出为0
System.out.println(ing.intValue());
// Byte构造函数中的参数可以是String,如果是int型则必须显式的转换为byte型
Byte by = new Byte((byte) 13);
System.out.println(by);
}
static void function(Integer i) {
i = new Integer(1);
}
}
AB4
ABC
0
false
null
0
13
public class CeilAndRoud {
public static void main(String[] args) {
// Math.ceil表示向上取整 返回12.0
System.out.println(Math.ceil(11.2));
// Math.floor表示向下取整 返回11.0
System.out.println(Math.floor(11.2));
// Math.round表示四舍五入 等于Math.floor(11.2+0.5) 返回11
System.out.println(Math.round(11.2));
// 返回12
System.out.println(Math.round(11.5));
}
}