程序源码如下:
public class PrimitiveClassTest{
public static void main(String[]args){
//Integer的使用
Integer i=new Integer(5);
System.out.println(i); //打印Integer的整数值
System.out.println("5+6="+(i.intValue()+6)); //获取Integer的整数值
System.out.println("5+6="+(Integer.parseInt("5")+6));//将字符串"5打印出来"
//Double的使用
Double d=new Double(2.5);
System.out.println(d);
System.out.println("2.5 * 2.5 ="+(d.DoubleValue()*2.5);
System.out.println("2.5 * 2.5 ="+(Double.parseDouble("2.5")*2.5));
//Boolean
boolean b=new Boolean(true);
System.out.println(b);
if(b.booleanValue()){
System.out.println("value of b is true");
}
if(Boolean.parseBoolean("true")){
System.out.println("true String had convert ivto a boolean type");
}
//Character
Character c=new Character('2');
System.out.println(c);
System.out.println(c.charValue());
if(Character.isDigit('3')){
System.out.println("3 is a digit");
}
if(Character.isLetter('c')){
System.out.println("c is a letter");
}
}
}
这是什么原因呢?