- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the lambda expression to convert array/List of String to array/List of Integers in java?
You can convert an array list of strings to an array list of integers as:
Example
import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class LamdaExpressions { public static void main(String args[]) { ArrayList <String> list = new ArrayList<String>(); list.add("123"); list.add("223"); list.add("323"); list.add("334"); List<Integer> listInteger = list.stream().map(s -> Integer.parseInt(s)).collect(Collectors.toList()); System.out.println(listInteger); } }
Output
[123, 223, 323, 334]
Advertisements
To Continue Learning Please Login
Login with Google