package WrapperTest;标签:包装,System,Boolean,Integer,println,new,out From: https://www.cnblogs.com/liujy2233/p/16795992.html
import org.junit.Test;
/**
* @author liu$
* @version 1.0
* @description: java提供了八种包装类,使得基本数据类型具有类的特征 int-Interger
* @date 2022.10.15$ $
*/
public class wrapp0 {
//包装类-->基本数据类型:调用包装类的xxxValue()
public void test2(){
Integer in1 = new Integer(12) ;
int i1 = in1.intValue() ;
System.out.println(in1+1);
Float f1 = new Float(13.4) ;
float f2 = f1.floatValue();
System.out.println(f2+1);
}
public void test(){
int num1 =10 ;
Integer in1 = new Integer(num1) ;
System.out.println(in1.toString());
Integer in2 = new Integer("123") ;
System.out.println(in2.toString());
//报异常
//Integer in3 = new Integer("123abc") ;
//System.out.println(in3.toString());
Boolean b1 = new Boolean(true) ;
Boolean b2 = new Boolean("True") ;
System.out.println(b2);
Boolean b3 = new Boolean("true123") ;
System.out.println(b3);//false
Order order = new Order() ;
System.out.println(order.isMale);
System.out.println(order.isFemale); //null此时为一个对象,初始值为null
}
}
class Order {
boolean isMale;
Boolean isFemale;
}