- 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 of() method in Java
The IntStream class in Java the following two forms of of() method
IntStream of(int t) method
The following of() method returns a sequential IntStream containing a single element. Here is the syntax
static IntStream of(int t)
Here, parameter t is the single element.
IntStream of(int… values) method
The following of() method returns a sequentially ordered stream whose elements are the specified values
static IntStream of(int… values)
Here, the parameter values are the elements of the new stream.
The following is an example to implement IntStream of() method in Java
Example
import java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.of(10, 20, 30, 40, 50); intStream.forEach(System.out::println); } }
Output
10 20 30 40 50
Advertisements