Program to convert List of String to List of Integer in Java Last Updated : 13 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The Java.util.List is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be stored. Since List preserves the insertion order, it allows positional access and insertion of elements. List Interface is implemented by ArrayList, LinkedList, Vector, and Stack classes. 1. Using Java 8 Stream API: A Stream is a sequence of objects that supports various methods that can be pipelined to produce the desired result. Java 8 Stream API can be used to convert List to List. Algorithm: Get the list of String.Convert List of String to Stream of String. This is done using List.stream().Convert Stream of String to Stream of Integer. This is done using Stream.map() and passing Integer.parseInt() method as lambda expression.Collect Stream of Integer into List of Integer. This is done using Collectors.toList().Return/Print the list of String.Program: Java // Java Program to convert // List<String> to List<Integer> in Java 8 import java.util.*; import java.util.stream.*; class GFG { public static void main(String args[]) { // Create a list of String List<String> listOfString = Arrays.asList("1", "2", "3", "4", "5"); // Print the list of String System.out.println("List of String: " + listOfString); // Convert List of String to List of Integer List<Integer> listOfInteger = listOfString.stream() .map(Integer::valueOf) .collect(Collectors.toList()); // Print the list of Integer System.out.println("List of Integer: " + listOfInteger); } } Output List of String: [1, 2, 3, 4, 5] List of Integer: [1, 2, 3, 4, 5] 2. Using Guava's List.transform(): Algorithm: Get the list of String.Convert List of String to List of Integer using Lists.transform(). This is done using passing Integer.parseInt() method as lambda expression for transformation.Return/Print the list of String. Program: Java // Java Program to convert // List<String> to List<Integer> in Java 8 // Using Guava's List.transform() import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; class GFG { // Generic function to convert List of // String to List of Integer public static List<Integer> convertStringListToIntList(List<String> listOfString, Function<String, Integer> function) { return listOfString.stream() .map(function) .collect(Collectors.toList()); } public static void main(String args[]) { // Create a list of String List<String> listOfString = Arrays.asList("1", "2", "3", "4", "5"); // Print the list of String System.out.println("List of String: " + listOfString); // Convert List of String to list of Integer List<Integer> listOfInteger = convertStringListToIntList(listOfString, Integer::parseInt); // Print the list of Integer System.out.println("List of Integer: " + listOfInteger); } } OutputList of String: [1, 2, 3, 4, 5] List of Integer: [1, 2, 3, 4, 5] Comment More infoAdvertise with us Next Article Program to convert List of String to List of Integer in Java R RishabhPrabhu Follow Improve Article Tags : Misc Java Java Programs Java - util package java-stream java-list Java-Stream-programs Java-String-Programs Java-List-Programs +5 More Practice Tags : JavaMisc Similar Reads Program to convert List of Integer to List of String in Java The Java.util.List is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be stored. Since List preserves the insertion order, it allows positional access and insertion of elements. List Interface is implemented by ArrayList, LinkedList, Vector and S 3 min read Program to convert set of String to set of Integer in Java Java Set is a part of java.util package and extends java.util.Collection interface. It does not allow the use of duplicate elements and at max can accommodate only one null element. A Stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result. 2 min read Java Program to Convert String to Integer Array In Java, we cannot directly perform numeric operations on a String representing numbers. To handle numeric values, we first need to convert the string into an integer array. In this article, we will discuss different methods for converting a numeric string to an integer array in Java.Example:Below i 3 min read Program to Convert Set of Integer to Array of Integer in Java Java Set is a part of java.util package and extends java.util.Collection interface. It does not allow the use of duplicate elements and at max can accommodate only one null element. A Stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result. 2 min read Program to Convert Set to List in Java Java Set is a part of java.util package and extends java.util.Collection interface. It does not allow the use of duplicate elements and at max can accommodate only one null element. The List is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be s 4 min read Program to Convert List to Stream in Java The List is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be stored. Since List preserves the insertion order, it allows positional access and insertion of elements. List Interface is implemented by ArrayList, LinkedList, Vector and Stack class 3 min read Java Program to Convert Integer List to Integer Array There are many ways to convert integer List to ArrayList where in this article we will be discussing out 2 approaches as below: Using concept od streams in Java8Using Apache Commons LangUsing Guava Library Method 1: Using concept od streams in Java8 So, first, we will get to know about how to conver 3 min read Java Program to Convert Long to String The long to String conversion in Java generally comes in need when we have to display a long number in a GUI application because everything is displayed in string form. In this article, we will learn about Java Programs to convert long to String. Given a Long number, the task is to convert it into a 4 min read Java Program to Convert InputStream to String Read and Write operations are basic functionalities that users perform in any application. Every programming language provides I/O streams to read and write data. The FileInputStream class and FileOutputStream class of Java performs I/O operations on files. The FileInputStream class is used to read 4 min read Java Program to Convert Enum to String Given an enum containing a group of constants, the task is to convert the enum to a String. Methods: We can solve this problem using two methods: Using name() MethodUsing toString() Method Let us discuss both of them in detail and implementing them to get a better understanding of the same. Method 1 2 min read Like