Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Program to convert List of String to List of Integer in Java
Here’s our List of String −
List<String> listString = Arrays.asList("25", "50", "75", "100", "125", "150");
Now, convert the list of string to list of integer −
List<Integer> listInteger = listString.stream().map(Integer::parseInt).collect(Collectors.toList());
Following is the program to convert List of String to List of Integer in Java −
Example
import java.util.*;
import java.util.stream.*;
import java.util.function.*;
public class Demo {
public static void main(String[] args) {
List<String> listString = Arrays.asList("25", "50", "75", "100", "125", "150");
System.out.println("List of String = " + listString);
List<Integer> listInteger = listString.stream().map(Integer::parseInt)
.collect(Collectors.toList());
System.out.println("List of Integer (converted from List of String) = " + listInteger);
}
}
Output
List of String = [25, 50, 75, 100, 125, 150] List of Integer (converted from List of String) = [25, 50, 75, 100, 125, 150]
Advertisements
