Java Language Lists Convert a list of integers to a list of strings

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

List<Integer> nums = Arrays.asList(1, 2, 3);
List<String> strings = nums.stream()
    .map(Object::toString)
    .collect(Collectors.toList());

That is:

  1. Create a stream from the list
  2. Map each element using Object::toString
  3. Collect the String values into a List using Collectors.toList()


Got any Java Language Question?