The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java 8 Map Function Examples

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Java 8 Map Function Examples Posted: Jan 31, 2015 4:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Java 8 Map Function Examples
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
Map is a well known functional programming concept which is incorporated into Java 8. Map is a function defined in java.util.stream.Streams class, which is used to transform each element of stream. Because of this property you can use Map in Java 8 to transform a Collection, List, Set or Map. For example, if you have a list of String and you want to convert all of them into upper case, how will you do this? Prior to Java 8, there is no function to do this. You had to iterate through List using a for loop or foreach loop and transform each element. In Java 8, you get stream, which allow you to apply many functional programming operator like map, reduce and filter. By using Map function you can apply any function to every element of Collection. It can be any predefined function or a user defined function. You not only can use lambda expression but also you can also use method references. Some examples of Map in Java 8 is to convert a list of integers and then square of each number. Map function is also an intermediate operation and it return a stream of transformed element. Stream API also provides methods like mapToDouble(), mapToInt(), and mapToLong() which returns DoubleStream, IntStream and LongStream, which are specialized stream for double, int and long data types. You can collect the result of transformation by using Collectors class, which provides several method to collect the result of transformation into List, Set or any Collection.
Read more ยป

Read: Java 8 Map Function Examples

Topic: How to allow users to customize the UI Previous Topic   Next Topic Topic: 10 capabilities we want to see in HTML6

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use