一、包装类体系图
Boolean类
Character类
Byte(Integer。。。)类
二、包装类和基本数据类型的转换
jdk5前是手动装箱和拆箱 :
public class WrapperType {
public static void main(String[] args) {
//手动装箱
int n1 = 100;
Integer integer = new Integer(n1);
Integer integer1 = Integer.valueOf(n1);//两种方法
// 手动拆箱
int i = integer.intValue();
}
}
jdk5后就可以自动装箱和拆箱
public class WrapperType {
public static void main(String[] args) {
int n1 = 200;
Integer integer = n1;//底层使用的是Integer.valueOf(n1)
int n3 = integer;//自动拆箱,底层依旧使用的是intvalue()
}
}
其他包装类方法类似
三、包装类和String类型的转换
以Integer和String为例
1.包装类型转String
public class WrapperType {
public static void main(String[] args) {
Integer n1 = 100;
//方式1
String str = n1 + "";
//方式2
String str1 = n1.toString();
//方式3
String str3 = String.valueOf(n1);
}
}
2.String转包装类型
public class WrapperType {
public static void main(String[] args) {
String str4 = "1234";
Integer n2 = Integer.parseInt(str4);//使用到了自动装箱
Integer n3 = new Integer(str4);//使用到了Integer的构造器第二种方法
}
}
四、包装类的常用方法
1.Integer的常用方法
public class WrapperWay {
public static void main(String[] args) {
System.out.println(Integer.MAX_VALUE);//返回最大值
System.out.println(Integer.MIN_VALUE);//返回最小值
}
}
2.Character的常用方法
public class WrapperWay {
public static void main(String[] args) {
System.out.println(Character.isDigit('a'));//判断是不是数字
System.out.println(Character.isLetter('a'));//判断是不是字母
System.out.println(Character.isUpperCase('a'));//判断是不是大写
System.out.println(Character.isLowerCase('a'));//判断是不是小写
System.out.println(Character.isWhitespace('a'));//判断是不是空格
System.out.println(Character.toUpperCase('a'));//转换成大写
System.out.println(Character.toLowerCase('A'));//转换成小写
}
}
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。