package com.google.common.primitives;、
Ints是int的工具类
说说Ints里面的方法;
1.public static List<Integer> asList(int... backingArray)
传入int类型数据,返回一个List<Integer> ,感觉像是比较常用的样子。
示例:List<Integer> list=Ints.asList(1,2,5,4);
2.public static int checkedCast(long value)
如果可能,返回等于value的int值。类型转换,long → int
3.public static int compare(int a, int b){ return a < b ? -1 : (a > b ? 1 : 0);}
这个看名字就直到了,有很多类似的方法,像Integer.compareTo(),或者比较器Comparator
4.public static int[] concat(int[]... arrays)
把给定的多个数组组合成一个数组。特意仔细读了源码,是按照传入数组的顺序,组合成新数组。
5.public static Integer tryParse(String string)
解析指定的字符串作为符号十进制整数。 用处不大的感觉,有这个 Integer.parseInt(String s)
6.public static int saturatedCast(long value)
返回最接近的int值。
7.pub