October 28, 2020

java.util.function.IntFunction implementation using modern java

IntFunction is a functional interface, it takes an int and returns a reference type. This reference type can be specified by using generic type specification. We can implement it in different ways. Implement using a regular class. private class IntFuncImpl implements IntFunction<Integer>{ @Override public Integer apply(final int intValue) { return Integer.valueOf(intValue); } } Implement using […]

Read more
October 28, 2020

Double Unary Operator Implementation using modern java

DoubleUnaryOperator is a functional interface that lives in java.util.function package. It has one function applyAsDouble, which takes a double and returns a double. It is called an UnaryOperator, because it performs it’s action on a single argument. And, that single argument is of double type that’s why it has Double in it’s name. We can implement […]

Read more
October 23, 2020

Implement Prototype Design Pattern Using Java Base libraries features.

Java provides inbuilt features to implement Prototype design pattern. But, before using that I will show you how you can create a prototype without any help from any libraries. So, we have a Person class. public class Person { private String firstName; private String lastName; private String country; public Person(){} public Person(final String firstName, final String lastName, […]

Read more
October 10, 2020

java.util.function.IntConsumer implementation using modern Java

In this post, I will show you different ways to implement java.util.function.IntConsumer functional interface. You can watch me coding all of these implementation on youtube. First one is a class implementation, where we use implements keyword to provide an implementation, we have been doing this since the start of Java. class IntCons implements IntConsumer{ @Override public void accept(final int […]

Read more
October 10, 2020

java.util.function.IntBinaryOperator implementation in modern Java

In this blog post, I will show you the different ways to implement java.util.function.IntBinaryOperator. You can watch my youtube video, where I code these implementation. A Regular Class.. private class RegularImpl implements IntBinaryOperator{ @Override public int applyAsInt(final int firstIntValue, final int secondIntValue){ return firstIntValue > secondIntValue ? firstIntValue : secondIntValue; } } Implementation using a […]

Read more