- 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
LongStream iterator() method in Java
The iterator() method of the LongStream class in Java returns an iterator for the elements of this stream.
The syntax is as follows.
PrimitiveIterator.OfLong iterator()
Here, PrimitiveIterator is an Iterator specialized for long values.
To use the LongStream class in Java, import the following package.
import java.util.stream.LongStream;
The following is an example to implement LongStream iterator() method in Java.
Example
import java.util.*; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(15000L, 17000L, 25000L); PrimitiveIterator.OfLong i = longStream.iterator(); while (i.hasNext()) { System.out.println(i.nextLong()); } } }
Output
15000 17000 25000
- Related Articles
- LongStream min() method in Java
- LongStream noneMatch() method in Java
- LongStream filter() method in Java
- LongStream forEach() method in Java
- LongStream max() method in Java
- LongStream rangeClosed() method in Java
- LongStream peek() method in Java
- LongStream empty() method in Java
- LongStream findFirst() method in Java
- LongStream of() method in Java
- LongStream anyMatch() method in Java
- LongStream toArray() method in Java
- LongStream summaryStatistics() method in Java
- LongStream boxed() method in Java
- LongStream sorted() method in Java

Advertisements