Arraylist para array

5 respostas
A

Tenho um arraylist de doubles e preciso convertê-lo num array. Como faço?

5 Respostas

J
ArrayList list = new ArrayList();

double[] array = list.toArray(new double[0]);

[]'s

A

Não funcionou, amigo. Veio a seguinte mensagem: "the method toArray[] in the ArrayList is not applicable for the arguments (double[]).

ViniGodoy

Não faz. Ou você gera um array Double[], ou faz no braço.

M

Para gerar um Double[] você faz:

Double[] array = list.toArray(new Double[0]);
A

Obrigado.

Criado 31 de janeiro de 2010
Ultima resposta 31 de jan. de 2010
Respostas 5
Participantes 4