10JAVA基础-常用类02

Arrays

工具类,构造方法私有
//将数组转变为字符串
String str = Arrays.toString(int[] value);
//对于原数组进行排序,升序
Arrays.sort(int[] arr);

基本数据类型包装类

包装类数据类型
Bytebyte
Shortshort
Integerint
Longlong
Floatfloat
Doubledouble
Characterchar
Booleanboolean

Integer与int互相转换

//int --->Integer
Integer inte = new Integer(int value);
Integer inte2 = new Integer(String value);//此处的String类型数据必须由数字组成
//Integer ---> int
int i = inte2.intValue();

int和String转换

//int --->String
String s = String.valueOf(int value);
//String ---> int
int i = Integer.ParseInt(String value);

JDK5以后新特性

//自动装箱
Integer inte = 10//执行过程
Integer inte = new Integer(10);
//自动拆箱
inte += 20;
//执行过程
inte = inte +20 // 自动拆箱,将inte 转换为int 与20相加,再自动装箱成Integer类型
inte = Integer.valueoOf(inte.intValue() +20);

Date

//构造方法
Date d1 = new Date();
Date d2 = new Date(long value);
//
long date1 = d1.getTime();//获取当前时间戳
long date2 = d2.getTime();//获取指定时间的时间戳
d1.setTime(long value);//设置时间

SimpleDateFormat

//date --->String
Date date = new Date();
SimpleDateFormat sft = new SimpleDateFormat(String format);//format :格式
String sDate = sft.format(date);
//String --->date
String date = "2010-10-10";
SimpleDateFormat sft = new SimpleDateFormat(String format);//format :格式
Date dDate = stf.parse(date);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值