¿Cómo crear ArrayList de un arreglo T[] en Java?

Supongamos que tenemos un arreglo del tipo:


Element[] array = {new Element(1),new Element(2),new Element(3)};

Si quisieramos convertirlo a un objeto de la clase ArrayList, la clase Arrays nos ofrece un método muy útil:



new ArrayList<Element>(Arrays.asList(array))

No hay comentarios:

Publicar un comentario