- 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
IntStream boxed() method in Java
The boxed() method of the IntStream class returns a Stream consisting of the elements of this stream, each boxed to an Integer.
The syntax is as follows.
Stream<Integer> boxed()
At first, create an IntStream
IntStream intStream = IntStream.range(20, 30);
Now, use the boxed() method to return a Stream consisting of the elements of this stream, each boxed to an Integer.
Stream<Integer> s = intStream.boxed();
The following is an example to implement IntStream boxed() method in Java.
Example
import java.util.*; import java.util.stream.Stream; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.range(20, 30); Stream<Integer> s = intStream.boxed(); s.forEach(System.out::println); } }
Output
20 21 22 23 24 25 26 27 28 29
Advertisements