- 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 asDoubleStream() method in Java
The asDoubleStream() method in the IntStream class returns a DoubleStream consisting of the elements of this stream, converted to double.
The syntax is as follows
DoubleStream asDoubleStream()
First, create an IntStream
IntStream intStream = IntStream.of(20, 30, 40, 50, 60, 70, 80);
After that, convert it to double with asDoubleStream() method
DoubleStream doubleStream = intStream.asDoubleStream();
The following is an example to implement IntStream asDoubleStream() method in Java
Example
import java.util.*; import java.util.stream.IntStream; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.of(20, 30, 40, 50, 60, 70, 80); DoubleStream doubleStream = intStream.asDoubleStream(); doubleStream.forEach(System.out::println); } }
Output
20.0 30.0 40.0 50.0 60.0 70.0 80.0
Advertisements