String和包装类型互相转换

1.String类型转换成包装类

     Double aDouble = Double.valueOf("12.66");//返回Double包装类型
        double aDouble1 = Double.parseDouble("12.66");//返回double基本数据类型

        Long aLong = Long.valueOf("123456");//返回Long包装类型
        long parseLong = Long.parseLong("123456");//返回long基本数据类型

        Integer integer = Integer.valueOf("123");///返回Integer包装类型
        int i = Integer.parseInt("123");//返回int基本数据类型

  

2.基本转换成String类型

        String s = Integer.toString(100);

        String s1 = Long.toString(10000);

        String s2 = Double.toString(26.66);

  

 

posted @ 2020-09-09 19:43  Amy清风  阅读(557)  评论(0编辑  收藏  举报