February 10, 2019

Using java lambda to provide implementation for Runnable interface.

There are many ways to create a thread. One of those ways is implementin Runnable interface. Again there are several ways to provide an implementation for it. One of those ways is, using lambda to provide an implementation. If you don’t know anything about lambda, then you can read it here. You are gonna need […]

Read more
January 7, 2019

Implementing java.util.function.DoubleBinaryOperator in java – functional programming.

DoubleBinaryOperator is a Functional Interface . It has only one abstract method and has no default method, unlike many other functional interfaces. It is a primitive type specialization of BinaryOperator. If we are trying to implement BinaryOperator for a double type, rather than doing that, we can use DoubleBinaryOperator for that. It has only one function. […]

Read more
December 4, 2018

Simple implementation for Callable interface in Java, using lambda.

In this tutorial, we will learn basic implementations for Callable interface  using lambda in java. Anonymous Class providing an implementation for Callable interface. Callable<String> callMyName = new Callable<String>() { @Override public String call() throws Exception { return “Anurag Anand”; } }; You can submit the above implementation to return any string value. The same can be […]

Read more
November 30, 2018

Using java lambda to create threads using runnable interface in java

I am using jdk-11 for this tutorial. We are going to use lambda functions to create a thread in java. In this tutorial, we will implement Runnable  interface. Our lambda implementation will print numbers from the range 1 to 10. Step 1 :- implement Runnable interface Runnable runThroughLambda = () -> IntStream.rangeClosed(1, 10) .forEach(System.out::println); In above code, I […]

Read more
November 28, 2018

What is lambdas in Java – Understanding Lamdas in Java

Lambdas were introduced in Java 8. For me they are first step towards functional programming in java. Lambdas are a little like anonymous class. They are similar in the way they are defined and passed around as a parameter in functions. But, lambdas are not exactly an anonymous class. After compilation, an anonymous class has […]

Read more
November 24, 2018

Using java streams to make your java code lazy

What do I mean by making your code lazy? Your code won’t do a single operation, until, output generated by it’s execution is not consumed by some other operation. It would look like the code is doing some action, but in reality it is not doing anything. Let’s dig into this by using an example […]

Read more