JAVA基础10-包装类


  1. 调用包装类构造器

  2. 示例:


public class WrapperTest {

    public static void main(String[] args) {

        int i1=10;

        Integer integer1=new Integer(i1);

        System.out.println(integer1.toString());

        //10

        Integer integer2=new Integer("10");

        System.out.println(integer2.toString());

        //10 字符串也可转,但字符串内必须是数字

        

        Boolean b1=new Boolean(true);

        System.out.println("b1" +b1);

        //b1true

        Boolean b2=new Boolean("true" );

        System.out.println("b2" +b2);

        //b2true 这里字符串也可转

        Boolean b3=new Boolean("true123");

        System.out.println("b3"+b3);

        //b3false 只有字符串"true"转出来时true,其他都为false

       

        Order o1=new Order();

        System.out.println(o1.isOK1);

        //null

        System.out.println(o1.isOk2);

        //false

    }



}

class Order{

    Boolean isOK1;// 类Boolean未初始化null

    boolean isOk2;// 基本数据类型未初始化false

}



包装类转为基本数据类型


  1. 调用包装类的XXXValue()

  2. 示例:


public class BasicTest {

    public static void main(String[] args) {

        Integer integer1=new Integer(10);

        int i1=integer1.intValue();

        System.out.println(i1 + 1);

        //11 类是不能做运算的,必需先转成基本数据类型

    }

    

}



  1. JDK 5.0新特性:自动装箱与自动拆箱

public class BasicTest {

    public static void main(String[] args) {

     	BasicTest basicTest=new BasicTest();

        int i2=20;

        basicTest.method(i2);

        // 自动转化为Object类的子类Integer

        // 20



        //自动装箱

        int num3=30;

        Integer integer3=num3;

        System.out.println(integer3.toString());

        // 30

       

        //自动拆箱

        int num4=integer3;

        System.out.println("num4" + num4);

        // num4 30 



    }

    public void method(Object object){

        System.out.println(object);

    }

}



基本数据类型,包装类转换为String类型


  1. 调用String的重载valueOf()

  2. 也可以直接运算基本数据类型+ “”

  3. 示例:


public class StringTest {

    public static void main(String[] args) {
跳槽是每个人的职业生涯中都要经历的过程,不论你是搜索到的这篇文章还是无意中浏览到的这篇文章,希望你没有白白浪费停留在这里的时间,能给你接下来或者以后的笔试面试带来一些帮助。



也许是互联网未来10年中最好的一年。WINTER IS COMING。但是如果你不真正的自己去尝试尝试,你永远不知道市面上的行情如何。这次找工作下来,我自身感觉市场并没有那么可怕,也拿到了几个大厂的offer。在此进行一个总结,给自己,也希望能帮助到需要的同学。

### 面试准备



面试准备根据每个人掌握的知识不同,准备的时间也不一样。现在对于前端岗位,以前也许不是很重视算法这块,但是现在很多公司也都会考。建议大家平时有空的时候多刷刷leetcode。算法的准备时间比较长,是一个长期的过程。需要在掌握了大部分前端基础知识的情况下,再有针对性的去复习算法。面试的时候算法能做出来肯定加分,但做不出来也不会一票否决,面试官也会给你提供一些思路。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值