Java包装类

包装类:
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类:
非当前时间的特定时间使用,
可以根据指定的年月日构建一个日历对象

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值