The difference between the list and Arrylist of java

List: is an ordered collection may contain duplicate elements. Provided by the index accessible way. It inherits Collection.
List two important implementation class: ArrayList and LinkedList
ArrayList: we can see it as able to automatically increase the capacity of the array .
Using the toArray ArrayList () returns an array.
Arrays.asList () returns a list. is an interface list, ArryList () is the implementation class interface list.
1.ArrayList underlying using arrays implemented, when used without parameters to the constructor when generating ArrayList object, actually at the bottom to generate a length 10 of type Object array
2. If the increased number of elements exceeds 10, so ArrayList the bottom will generate a new array, the length of 1.5 times the original array of +1, which is then copied to the new array of the original contents of the array, and subsequent additions are placed among the new array. When the new array can not accommodate additional elements, repeat the process.
3. For ArrayList delete operation element, the element needs to be removed to a subsequent forward movement of the element, the price is relatively high.
4. The collection of objects which can only be placed references to be placed native data type , we need to use the native data types of packaging which can be added to the collection.
5 are placed among a set of type Object, thus taken out is of type Object, you must useCast converted to true (the type of placement into)

Guess you like

Origin www.cnblogs.com/had1314/p/10991805.html