It’s a fairly common task for a Java developer to convert a list to an array or from an array to a list. Like many things in Java, there is often more than one way to accomplish a task. In this post, I’ll discuss the various approaches to converting data between list objects and arrays.

Converting List to Array

The list interface comes with the toArray() method that returns an array containing all of the elements in this list in proper sequence (from the first to last element). The type of returned array is that of the array that you pass as the parameter.

Source de l’article sur DZONE

0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.