話不多說,直接上代碼
//將一個(gè)原始的數(shù)組original,從下標(biāo)from開始復(fù)制,復(fù)制到上標(biāo)to,生成一個(gè)新的數(shù)組。
Arrays.copyOfRange(T[ ] original,int from,int to)
//實(shí)現(xiàn)把兩個(gè)數(shù)組合并為一個(gè)的方法
ArrayUtils.addAll(Object[], Object[])
//將指定源數(shù)組中的數(shù)組從指定位置復(fù)制到目標(biāo)數(shù)組的指定位置
System.arraycopy(Object src, int srcPos,Object dest, int destPos,int length)
//int[ ] 轉(zhuǎn) Integer[ ]
Integer[] integers = Arrays.stream(arr).boxed().toArray(Integer[]::new);
//Integer[ ]轉(zhuǎn) int[ ]
int[] arr= Arrays.stream(integers).mapToInt(Integer::valueOf).toArray();
//Integer[ ]轉(zhuǎn) List<Integer>
List<Integer> list = Arrays.asList(integers);
//List< Integer > 轉(zhuǎn) Integer[ ]
Integer[] integers = list.toArray(new Integer[list.size()]);
//集合根據(jù)一個(gè)元素去重
List<UserInfo>collect=list.stream().
collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(UserInfo::getUsername))),ArrayList::new));