高级API

*高级API 
 java.lang.* : java基础包,一般不需要导入包.
 java.util.* : java工具包
 java.io.*:  java数据读写包

*java.lang.* 
   Integer:该类还提供了一些将int转换为String和String转换为int ,以及在处理int时有用的其他常量和方法.

   1. int -> Integer
   Integer it1 = new Integer(15);
   Integer it3 = Integer.valueOf(22);
      
   
   2. String -> Integer
   Integer it2 = new Integer("20");
   Integer it4 = Integer.valueOf("30");


   3. Integer -> int
   int value = it1.intValue();

   
   4.String -> int
   int number = Integer.parseInt("16",8);

   5.Integer -> String
   String str = it1.toString();


   6.int -> String
   String str2 = Integer.toString(18,8); //"18"
   String str3 = String.valueOf(111);

重点
Java中的`Boolean(java.lang.String)`构造函数已经被弃用,并在Java 8中正式移除。从Java 9开始,如果你需要将字符串转换为布尔值,可以使用`java.lang.Boolean.parseBoolean()`方法也可以用Boolean.value.Of()。

自动拆、装箱
自动装箱:
Integer i = 18;编译器会自动把基本类型int 18 包装成包装类型Integer,然后交给Integer的类型的变量来保存,底层发生的代码实际是:Integer.valueOf(18); 自动装箱的方向 int【基本类型】 => Integer【包装类型】
自动拆箱:
int i1 = i;编译器会自动把包装类型i拆掉“箱子”,变回基本类型的数据18,然后交给基本类型的变量i1来保存,底层代码:int i1 = i.intValue();,自动拆箱的方向:Integer【包装类型】 => int【基本类型】

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值