Okay So this doesnt make sense to me.... maybe someone can shed some light. A technique I figure out for converting primitive arrays into ArrayLists is as follows.
arr = new ArrayList<String>(Arrays.asList(primitveArray));
this works quit well.
But today, I start wondering how efficent this was, since I happened to be writing some code where performance is more important then It had been in other applications I had worked on in the past and decided to look at the source code for Arrays.asList()
我发现了这个:
public static <T> List<T> asList(T... array) {
return new ArrayList<T>(array);
}
我对自己说:“我真是个白痴,它只是将数组传递给ArrayList构造函数ArrayList<;T>;(T[]arr)
,为什么我不跳过一步,不使用愚蠢的Arrays.asList呢?
所以我试试这个
arr = new ArrayList<T>(primitveArray)
在我的代码中。但突然数组列表<;T>;(T[]arr)
未定义。我很困惑为什么会这样?