2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Java: Best way of converting List<Integer> to List<String>

There is a list of integers, List<Integer> and I"d like to convert all the integer objects into Strings, thus finishing up with a new List<String>.

Naturally, I could create a new List<String> and loop through the list calling String.valueOf() for each integer, but I was wondering if there was a better (read: more automatic) way of doing it?


you can iterate and instantiate is the only way to do this. Something like (for others potential help, since I'm sure you know how to do this)

List<Integer> oldList = ...

/* Specify the size of the list up front to prevent resizing. */

List<String> newList = new ArrayList<String>(oldList.size()) 

for (Integer myInt : oldList) { 



Answer is