Arrays是java容器相關操做的工具類,asList方法將Array轉換爲list,是Array和List之間的橋樑。java
Arrays.asList返回一個基於參數array的fixed list,即不能對返回的list進行修改操做,如刪除操做、增長操做等。若是想得到可修改的List,那麼可採用以下方式操做:app
new ArrayList<Integer>(Arrays.asList(arr)) 注:then you create new ArrayList, which is a full, independent copy of the original one. Although here you create the wrapper using Arrays.asList as well, it is used only during the construction of the new ArrayList and is garbage-collected afterwards. The structure of this new ArrayList is completely independent of the original array. It contains the same elements (both the original array and this new ArrayList reference the same integers in memory), but it creates a new, internal array, that holds the references. So when you shuffle it, add, remove elements etc., the original array is unchanged. new LinkedList<Integer>(Arrays.asList(arr)) 注:LinkedList支持更快的remove操做。