包装类:
1、是基本数据类型的封装
2、是基本数据类型与引用数据类型转换的桥梁
int -- Integer{
1、根据一个int变量,转换成它对应的Integer对象
Integer in = new Integer(100); //标准做法
Integer in1 = 100; //自动装箱,这是JDK1.5提供的语法糖
2、根据一个Integer对象,将它的值放到一个int变量中
Integer in = 100;
int a = in.intValue(); //标准做法
int b = in; 自动拆箱,这是JDK1.5提供的语法糖
}
String -- Integer{
1、String转Integer
String str = "123";
Integer in = new Integer(str);
2、Integer转String
Integer in = 30;
String str =in.toString();
String str1 = in+""; //当对对象做字符串拼接操作,相当于默认调用对象的toString方法
}
String -- int{
1、int转String
int a = 120;
String str = Integer.toString(a);
String str1 = a+"";
2、String转int
String str = "2500";
int a = Integer.parseInt(str);
}
如何查API doc:
时间.日期类: 在计算机中,保存时间用的是long类型
记录的是当前距离1970年1月1号,0:00:00:000过了多少毫秒
Date类: 产生的Date对象,里面封装的是当前时间的信息
Date中的after、before、compareTo、equals这些时间日期比较的方法还能继续使用
在输出Date的字符串信息是,通常配合使用SimpleDateFormat这个类
Calendar类:
非当前时间的特定时间使用,
可以根据指定的年月日构建一个日历对象
1、是基本数据类型的封装
2、是基本数据类型与引用数据类型转换的桥梁
int -- Integer{
1、根据一个int变量,转换成它对应的Integer对象
Integer in = new Integer(100); //标准做法
Integer in1 = 100; //自动装箱,这是JDK1.5提供的语法糖
2、根据一个Integer对象,将它的值放到一个int变量中
Integer in = 100;
int a = in.intValue(); //标准做法
int b = in; 自动拆箱,这是JDK1.5提供的语法糖
}
String -- Integer{
1、String转Integer
String str = "123";
Integer in = new Integer(str);
2、Integer转String
Integer in = 30;
String str =in.toString();
String str1 = in+""; //当对对象做字符串拼接操作,相当于默认调用对象的toString方法
}
String -- int{
1、int转String
int a = 120;
String str = Integer.toString(a);
String str1 = a+"";
2、String转int
String str = "2500";
int a = Integer.parseInt(str);
}
如何查API doc:
时间.日期类: 在计算机中,保存时间用的是long类型
记录的是当前距离1970年1月1号,0:00:00:000过了多少毫秒
Date类: 产生的Date对象,里面封装的是当前时间的信息
Date中的after、before、compareTo、equals这些时间日期比较的方法还能继续使用
在输出Date的字符串信息是,通常配合使用SimpleDateFormat这个类
Calendar类:
非当前时间的特定时间使用,
可以根据指定的年月日构建一个日历对象