Arrays、Date、System、Math

Arrays

  • toString(type[] arr):将数组转换为字符串展示
  • sort(type[] arr):将数组按照升序排列
  • copyOfRange(type[], start, end):复制数组的一部分或者整个数组
  • binarySearch(type[], start, end, char):在数组索引范围内用二分查找法查找字符串,返回字符下标,没有返回-1
  • fill(type[], char):将数组的值设为char
  • equals(typeA[], typeB[]):判断两个数组是否相同

数组方法

  • 检查数组是否包含某个值
String[] stringArray = { "a", "b", "c", "d", "e" };  
boolean b = Arrays.asList(stringArray).contains("a");  
// true  
System.out.println(b);  
  • 合并两个数组
  • 用字符连接数组的值
  • 数组移除元素

Date

  • 时间转为字符串
/*
 * 时间转换为时间字符串
 */
public static String  date2string(Date time, String format) {
	SimpleDateFormat sdf = new SimpleDateFormat(format);
	return sdf.format(time);
}

  • 字符串转化为时间

	public static Date string2time(String timeStr, String format) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.parse(timeStr);
	}

Calendar

  • public static Calendar getInstance() //获取日期对象
  • public int get(int field)   //获取时间字段值,年,月,日,时,分,秒
  • public void add(int field,int amount)   //指定字段增加某
  • public final void set(int field,int value)//设置指定字段的值
  • public final Date getTime() //获取该日历对象转成的日期对象

System

  • currentTimeMillis():获取当前系统时间的毫秒值
  • exit(int status) 用来结束正在运行的Java程序。参数传入一个数字即可。通常传入0记为正常状态,其他为异常状态
  • gc() 用来运行JVM中的垃圾回收器,完成内存中垃圾的清除。
  • getProperty(String key) 用来获取指定键(字符串名称)中所记录的系统属性信息

Math

  • abs
  • ceil
  • floor
  • max
  • min
  • round
  • random

转载于:https://my.oschina.net/chinahufei/blog/3035753

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值