ArrayList

2 respostas
J

Eu to tentando retorna um valor na posição 0, mas da “incompatible types”

ArrayList destino = new ArrayList();

    public int getDestino()
{	
	return destino.get(0);
}

o q pode estar errado?

2 Respostas

L

o get de ArrayList retorna um objeto e naum o tipo primitivo int

tenta

ArrayList destino = new ArrayList();

	public Integer getDestino() {
		return (Integer) destino.get(0);
	}

ou para java 5

ArrayList<Integer> destino = new ArrayList<Integer>();

	public Integer getDestino() {
		return destino.get(0);
	}
[/code]
J

vlw kra, obrigadão! :grin:

Criado 12 de outubro de 2006
Ultima resposta 12 de out. de 2006
Respostas 2
Participantes 2