November 19, 2021

Let user handle null case, using functional programming in modern java

When pass an object to a function, then there is a scenario which always arises. That, the passed object could be null. And, we have to write logic to react to that null-condition. And, generally that logic is hard-coded in the function. And, there are times as a user I feel that, instead of throwing an exception […]

Read more
October 7, 2020

java.util.function.Function implementation using modern java.

In this blog, I will show you the different ways to implement java.util.function.Function interface in modern java. You can watch me code these examples on youtube. First implementation is using implementation keyword in a regular class private class FuncImpl implements Function<Person, Integer>{ @Override public Integer apply(final Person person){ return person.getAge(); } } Second way uses anonymous class for implementation. […]

Read more
February 17, 2019

Using anonymous class to implement runnable interface in java

You can read about the other ways for implementing runnable interface – using a java class, and using lambda. In this part, we will use anonymous class for doing this. In my opinion, at the time of writing this article, the anonymous class is pretty useless now. If you need an anonymus class then use […]

Read more
February 10, 2019

How to implement java.util.function.DoubleToLongFunction

java.util.function.DoubleToLongFunction is a primitive specialization of Other Functional Interfaces. What it means is , we can get the same functionality using other functional interfaces, but they are going to be slow. Because of boxing and unboxing. If you are dealing with Double and Long wrapper objects then use other functional interface. So, this functional interface is […]

Read more
January 26, 2019

What are effective final variables in java, and where we can use it.

There is a final keyword, which is used to make a reference value permanent. It means – the value can not be changed once defined. Then there is effective final variable. These variables are not declared final. But, depending on the context they can be considered as final. What do i mean from a context? you should […]

Read more
January 26, 2019

Create a complete binary tree from an array of data in java

Note :- Using java 8 and above. Hi there… Today, I am going to write a java program which will take an var-arg of character, you can use any data-type you want. Data type is not the focus here. The main focus is the  process of creating a binary tree. I am using functional programming to do […]

Read more
January 21, 2019

How to implement java.util.function.DoubleToIntFunction in java

java.util.function.DoubleToIntFunction is a Functional Interface. It has only one method, and that is an abstract method. This abstract method is declared to accept one double value as an input-parameter, and it returns an int value. Both, input and output are primitives. These classes are specialized versions for primitive. As JVM doesn’t need to do boxing and unboxing. […]

Read more
January 19, 2019

Implement java.util.function.DoubleSupplier to return random numbers – java 11 and above

java.util.function.DoubleFunction is a Functional Interface. It has one abstract method, which takes no input but returns a double value. It can be used as a supplier of double values, and it can be used to create a doublestream double getAsDouble() :- it returns a double value, that’s all it’s declaration says. In this article, we will write an […]

Read more
January 18, 2019

How to Implement java.util.function.DoublePredicate’s function – test, and, or and negate in java

This code should run in java 11 and above. It definitely needs – above java 8. Few things will work in java 9 or 10. But, code should successfully run in java 11 and above. Because, I am running java 11. So, In this episode of java wonderland, we are going to implement java.util.function.BinaryPredicate.  Those who […]

Read more
January 11, 2019

Implementing java.util.function.DoubleConsumer in java, and using random numbers to test it.

Java provides a lot of Functional Interface , some are generic , can be used by all the data-types, whereas some are specialised for primitive types. Reasons, that I can think of are, they are a providing interfaces, which are going to be used most often second, they are providing some compiler magic to optimize these interfaces. […]

Read more