Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The ArrayList instance has an initial capacity of 110% the size of the specified collection.
Parameters:
c - the collection whose elements are to be placed into this list.
Throws:
NullPointerException - if the specified collection is null.
Kra seu eu compreendi bem sua pergunta os a ArrayList cria um array que cresce dinamicamente ou diminui dinamicamente. Seu tamanho depende da quantidade de valores que vc insere ou retira.
[quote=anderson.bonavides]Kra seu eu compreendi bem sua pergunta os a ArrayList cria um array que cresce dinamicamente ou diminui dinamicamente. Seu tamanho depende da quantidade de valores que vc insere ou retira.
É isso que vc ta querendo saber?[/quote]
Não… esse eu sei… a questão é:
No construtor de um arrayList eu posso passar um numero (que será o tamanho que ele irá iniciar) e
tenho a opção de passar uma collection…
public ArrayList(Collection<? extends E> c) {
size = c.size();
// Allow 10% room for growth
int capacity = (int) Math.min((size*110L)/100, Integer.MAX_VALUE);
elementData = (E[]) c.toArray(new Object[capacity]);
}
Pelo que entendi, ele apenas converte o Collection em Array e monta o ArrayList normalmente… a diferença esta nesse tamanho de 110% que ele cria… n entendi o motivo dessa capacidade, mas me parece ser por causa de segurança ou por alguns metadados que o Collection deve possuir no método toArray() e o ArrayList não…