public class Copy
{
public static void main(String[] args)
{
List source = Arrays.asList("three Two Yo Yo six five Four".split(" "));
List dest=Arrays.asList("in the matrix".split(" m"));
Collections.copy(dest,source);
System.out.println(dest);
}
}
不知道这里为什么会抛出异常?
public static <T> void copy(List<? super T> dest, List<? extends T> src) {
int srcSize = src.size(); //源数组
if (srcSize > dest.size())
throw new IndexOutOfBoundsException("Source does not fit in dest");
//若源数组的size() > 目标数组的size()则抛出IndexOutOfBoundsException