Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to convert List of Integer to List of String in Java
Here’s our List of Integer −
List<Integer> listInteger = Arrays.asList(25, 50, 75, 100, 125, 150);
Now, convert List of Integer to List of String −
List<String> listString = listInteger.stream() .map(s -> String.valueOf(s)) .collect(Collectors.toList());
Following is the program to convert List of Integer to List of String in Java −
Example
import java.util.*;
import java.util.stream.*;
import java.util.function.*;
public class Demo {
public static void main(String[] args) {
List<Integer> listInteger = Arrays.asList(25, 50, 75, 100, 125, 150);
System.out.println("List of Integer = " + listInteger);
List<String> listString = listInteger.stream()
.map(s -> String.valueOf(s))
.collect(Collectors.toList());
System.out.println("List of String (converted from List of Integer) = " + listString);
}
}
Output
List of Integer = [25, 50, 75, 100, 125, 150] List of String (converted from List of Integer) = [25, 50, 75, 100, 125, 150]
Advertisements