- 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
Java Program to convert integer to String with Map
Let’s say we have an Integer array with the following elements:
20, 50, 100, 200, 250, 300, 500, 550, 600, 700
Convert it to List:
Arrays.asList(20, 50, 100, 200, 250, 300, 500, 550, 600, 700)
Use Map to get the values greater than 400 and convert to String:
filter(val -> val > 400) .map(val -> "Value greater than 400 = " + String.valueOf(val))
The following is an example to convert integer to String with Map:
Example
import java.util.Arrays; public class Demo { public static void main(String[] args) { Arrays.asList(20, 50, 100, 200, 250, 300, 500, 550, 600, 700) .stream() .filter(val -> val > 400) .map(val -> "Value greater than 400 = " + String.valueOf(val)) .forEach(val -> System.out.println(val)); } }
Output
Value greater than 400 = 500 Value greater than 400 = 550 Value greater than 400 = 600 Value greater than 400 = 700
Advertisements