Before Java 8 :
Apache Commons Collections :
After Java 8 :
List<Personne> targetList = Arrays.stream(sourceArray).boxed().collect(Collectors.toList());
List targetList =
new
ArrayList(Arrays.asList(sourceArray));
Apache Commons Collections :
Personne[] sourceArray = { P
0
, P
1
, P
2
, P
3
, P
4
, P
5
};
List targetList =
new
ArrayList<>(
6
);
CollectionUtils.addAll(targetList, sourceArray);
After Java 8 :
List<Personne> targetList = Arrays.stream(sourceArray).boxed().collect(Collectors.toList());
Aucun commentaire:
Enregistrer un commentaire
to criticize, to improve