There’s a lot of confusion about “functions” in Java. Java doesn’t really have them, but an object could represent a function so it kind of does have them. I try to explain the different meanings of “functions” in Java, other languages and in mathematics.
Continue reading “Functions in Java”Tag: functional programming
Functional Programming in Java 8
Functional Programming made easy!
Continue reading “Functional Programming in Java 8”
Recursive Closures in Java
In Java you can only reference final fields inside a closure. Here’s my solution*.
Continue reading “Recursive Closures in Java”Java 8 Currying
Currying is great to spice up your code! But this is not about cooking.
Continue reading “Java 8 Currying”Why a Consumer is not a Function.
java.util.function.Consumer
does not extend java.util.function.Function
. But what if you want a set of both types? Why isn’t there a ConsumerFunction?
A ConsumerFunction is not defined in java.util.function
. You can easily do it yourself. But you will see that it’s not that simple. void
is a keyword in Java. There is a class Void
and (by reflection) you can even get an instance of Void
. But you have to use a return statement to get a Function
.
Misnomer: @FunctionalInterface
So it’s functional, right? Then why isn’t it a function? I’ll try to explain.
Continue reading “Misnomer: @FunctionalInterface”