數組、ArrayList、List、LinkedList的區別

一、數組 數組在內存中是連續存儲的,所以它的索引速度非常快,而且賦值與修改元素也很簡單。 1、一維數組 聲明一個數組: int[] array = new int[5];   初始化一個數組: int[] array1 = new int[5] { 1, 3, 5, 7, 9 }; //定長 聲明並初始化: int[] array2 = { 1, 3, 5, 7, 9 }; //不定長   2、
相關文章
相關標籤/搜索