package com.xukaiqiang.ArrayList;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.util.CollectionUtils;
/**
* 数组的合并,集合判断是否为空
*/
public class App {
public static void main(String[] args) {
int[] first = { 0, 1, 2, 3 };
int[] second =null;
int[] both = ArrayUtils.addAll(first, second);
for (int i : both) {
System.out.println(i);
}
List<String> list=new ArrayList<String>();
System.out.println(CollectionUtils.isEmpty(list));
}
}
public static int[] addAll(final int[] array1, final int... array2) {
if (array1 == null) {
return clone(array2);
} else if (array2 == null) {
return clone(array1);
}
final int[] joinedArray = new int[array1.length + array2.length];
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
return joinedArray;
}
public static boolean isEmpty(Collection<?> collection) {
return (collection == null || collection.isEmpty());
}
public boolean isEmpty() {
return size == 0;
}
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
}