
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
Advertisements