Using FFF in Java 8 …

FFF in java 8 means a function that take function and return function.

Suppose in a domain system , we are to find the highest time spent by all user.

import com.herokuapp.my_app_1;
public class TimeDomain

       public Collection<String> timeSpent ( Map<String,List<Long>> userInfo )
                            Collection<String> maxTimeSpent = Stream.of(userInfo)
                                     .filter( (month , hour) -> monthly % 30 != 0
                                     ||dailyTime >= 1200 )
                                     .max ( Comparing.compararing
                                     ( mothnlyActvities -> monthlyActivities
                                     .getLength() ) )
             return maxTimeSpent; 

The above code snippet is called FFF i.e a function that take function and return function

The task is to find the maximum time spent by each user, breaking  down the task we have

1.Ordering to find each time spent by each user

2. Informing the Stream the ordering type for each user time using comparator

3. Use comparing static method of Comparator to build the comparator keys

This is the main disguise of FFF -> Function that takes Function and Return Function

max is a Function , it takes comparaing Function and return getLength() Function.


Hope this make a little sense to you…. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: