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