- 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
DoubleStream count() method in Java
The count() method of the DoubleStream class returns the count of the elements in the stream.
The syntax is as follows:
long count()
To use the DoubleStream class in Java, import the following package:
import java.util.stream.DoubleStream;
Create DoubleStream and add some elements:
DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9);
Now, get the count of elements in the DoubleStream:
long res = doubleStream.count();
The following is an example to implement DoubleStream count() method in Java:
Example
import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.of(50.8, 67.9, 35.7, 23.6, 89.9); long res = doubleStream.count(); System.out.println("Count of elements in the stream = "+res); } }
Output
Count of elements in the stream = 5
Advertisements