This has been answered a million times (I get a million results on google). But my answer is the most bestest!Continue reading “Why is String immutable?”
String.length() gives the length of the String, right? Or does it?
Just a prototype so far:
The generic types of the arguments are always A, B, C, etc. The result is of generic type R.
It’s my goal to have three forms:
- Method/Lambda Form: Takes n arguments
- Curried Form: Methods are chained
A -> B -> C -> ... -> R
- Uncurried Form: Takes a tuple
(A,B,C,...) -> R
The idea is to add all the basic functions of Haskell to a project that then uses javatuples.org to have a way of using tuples for functional programming in Java 8.
- curry / uncurry
- zip / unzip
- composition (“.”-operator in Haskell)
- pipes (“|>” in F#)
- partial application
fn.arity()returns the arity of the function.
- Convert Suppliers and Consumers to Functions.
There’s still a lot to do…
List of TODOs:
- Implementations of
Quad ... Decade
- Unit-Tests (instead of FunctionalDemo.java)
Uncurriedfor such forms of the methods
Contact me on github if you are interested in this project.
Currying is great to spice up your code! But this is not about cooking.Continue reading “Java 8 Currying”
Arrays of generic types are often hard to create and handle. I’ll show you how to create an array of a class with a generic parameter.
No, it’s not. In reflection both extend
Constructor does not extend
Method. It is a common misconception that constructors are methods and often asked about at job interviews.
Continue reading “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
This is often asked at interviews. I’ll explain when to answer “yes” and when to answer “no”.
Continue reading “Is Java object-oriented?”
They do! And so do most online tutorials. Buy a good book instead!
Continue reading “Blogs about Programming suck!”
So it’s functional, right? Then why isn’t it a function? I’ll try to explain.
Continue reading “Misnomer: @FunctionalInterface”