基本数据类型的封装类
1,如何查看API,下载,然后ctrl+F
2,byte Byte
char Character
short Short
int Integer
long Long
float Float
double Double
3,自动装箱与拆箱
基本数据类型 转换为 封装类型:装箱
封装类型 转换为 基本类型:拆箱
拆箱示例:
Integer i1=new Integer(10);
1,如何查看API,下载,然后ctrl+F
2,byte Byte
char Character
short Short
int Integer
long Long
float Float
double Double
boolean Boolean
3,自动装箱与拆箱
基本数据类型 转换为 封装类型:装箱
封装类型 转换为 基本类型:拆箱
拆箱示例:
Integer i1=new Integer(10);
int i2=i1;
package com.in;
public class TestBoolean {
public static void main(String[] args) {
Boolean b1=new Boolean("true");
System.out.println(b1);
Boolean b2=new Boolean(false);
}
}
public class TestDouble {
public static void main(String[] args) {
System.out.println("Double最大值"+Double.MAX_VALUE);//1.7976931348623157E308
System.out.println("Double最小值"+Double.MIN_VALUE);//4.9E-324
double d=Double.parseDouble("123");
System.out.println(d);
System.out.println(Double.POSITIVE_INFINITY);
System.out.println(Double.NEGATIVE_INFINITY);
}
}
/**
* 123.0
* Infinity
* -Infinity
*/
package com.in;
public class TestInteger {
public static void main(String[] args) {
System.out.println("Integer的最大值:"+Integer.MAX_VALUE);
System.out.println("Integer的最小值:"+Integer.MIN_VALUE);
int i=Integer.parseInt("123");
System.out.println(i);
String s=Integer.toBinaryString(10);//二进制字符串
System.out.println(s);
}
}
/**
* Integer的最大值:2147483647
* Integer的最小值:-2147483648
* 123
* 1010
*/
package com.in;
public class Test {
public static void main(String[] args) {
Integer i1=new Integer(10);
int i2=i1;
System.out.println(i2);//10拆箱
int i3=9;
Integer i4=i3;
System.out.println(i4);//9装箱
}
}