1.包装类的概念
2.装箱与拆箱
3.自动拆箱和自动装箱
4.基本数据类型与字符串
Demo02Integer.java
package Interger;
/*
* 基本类型与字符串之间的转换
* 基本类型--》字符串
* 1.基本类型数据的值+”“最简单的方式
* 2.使用包装类中的静态方法
* static String toString(int i)返回一个表示指定整数的String对象
* 3.使用String类中的静态方法
* static String valueOf(int i)返回int参数的字符串表示形式
* 字符串————》基本类型
*
* */
public class Demo02Integer {
public static void main(String[] args) {
//1.基本类型转字符串
//必须确实是某种数据类型,否则会报数字格式化异常
String str1 = 3 + "";
System.out.println(str1);//3
//2.字符串转基本类型(以int为例)
int i = java.lang.Integer.parseInt("123");
System.out.println(i);//123
}
}