- Trending Categories
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 parallel() method in Java
The parallel() method of the IntStream class in Java returns an equivalent parallel stream. The method may return itself, either because the stream was already parallel, or because the underlying stream state was modified to be parallel.
The syntax is as follows:
IntStream parallel()
Create an IntStream and you can use the range() method as well to set the range of elements:
IntStream intStream = IntStream.range(20, 35);
Now, use the parallel() method:
intStream.parallel()
The following is an example to implement IntStream parallel() method in Java
Example
import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.range(20, 35); System.out.println("Parallel IntStream = "); intStream.parallel().forEach(System.out::println); } }
output
Parallel IntStream = 29 30 28 27 31 25 32 22 34 33 21 26 23 20 24
Advertisements