- 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
DoubleStream iterator() method in Java
The iterator() method of the DoubleStream class in Java returns an iterator for the elements of this stream.
The syntax is as follows
PrimitiveIterator.OfDouble iterator()
Here, PrimitiveIterator.OfDouble is an Iterator specialized for double values.
To use the DoubleStream class in Java, import the following package
import java.util.stream.DoubleStream;
The following is an example to implement DoubleStream iterator() method in Java
Example
import java.util.*; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.of(50.6, 69.8, 81.8, 95.6, 106.9); PrimitiveIterator.OfDouble res = doubleStream.iterator(); while (res.hasNext()) { System.out.println(res.nextDouble()); } } }
Output
50.6 69.8 81.8 95.6 106.9
Advertisements