

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Map to get substring and convert to int in Java
Let’s say the following is our stream:
Stream.of("u2", "h9", "s8", "l3")
Now, map to get the substring:
.map(s -> s.substring(1))
Convert to int and find the minimum:
.mapToInt(Integer::parseInt) .min()
The following is an example to Map and get substring and convert to int:
Example
import java.util.stream.Stream; public class Demo { public static void main(String[] args) throws Exception { Stream.of("u2", "h9", "s8", "l3") .map(s -> s.substring(1)) .mapToInt(Integer::parseInt) .min() .ifPresent(System.out::println); } }
Output
2
- Related Questions & Answers
- Convert String to Java int
- Convert int to String in Java
- How to Map double to int Object with mapToInt and mapToObj in Java?
- How to convert int to String in java?
- Map to create new value from int array in Java
- Java Program to convert a Map to a read only map
- Java Program to convert a String to int
- Java Program to convert int to binary string
- Java Program to convert int to Octal String
- Java Program to convert mathematical string to int
- Java Program to convert int array to IntStream
- Java Program to convert positive int to negative and negative to positive
- How to convert a Java String to an Int?
- Java Program to convert an int value to String
- How to convert a String to an int in Java
Advertisements