There are two problems with representing monads in Java:
flatMap needs to use a function that returns (the same) specific monad, and a system like Java cannot express this.
unit is a kind of static method in terms of Java, since it creates an instance of a monad from a common meaning. Java 8 has static methods on interfaces, but the abstract monad interface cannot know the implementation, so you need to use the factory method somewhere else (or just use the constructor).
As @AlexeyRomanov suggested, you can implement certain monads (for example, make the Option interface), but the abstract concept of a monad is not possible in Java. This, of course, means that you cannot create all those useful functions that work for any monad.
source share