![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 mapToDouble() method in Java
The mapToDouble() method returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
The syntax is as follows:
DoubleStream mapToDouble(LongToDoubleFunction mapper)
The parameter mapper is a stateless function to apply to each element.
To use the LongStream class in Java, import the following package:
import java.util.stream.LongStream;
The following is an example to implement LongStream mapToDouble() method in Java
Example
import java.util.stream.LongStream; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(5000L, 12000L, 15000L, 20000L, 25000L); DoubleStream s = longStream.mapToDouble(a → (double)a); System.out.println("Elements of DoubleStream..."); s.forEach(System.out::println); } }
output
Elements of DoubleStream... 5000.0 12000.0 15000.0 20000.0 25000.0
Advertisements