Functional Programming in Java [closed]

2022-08-31 16:17:00

Is there a good library for functional programming in Java?

I'm looking for stuff like Predicate and List.Find() (as a static method). Not complicated to implement, but it would be nice to find a reusable library here.


答案 1

FunctionalJava is the best known library; it makes use of Java closures (BGGA) for examples:

final Array<Integer> a = array(1, 2, 3);  
final Array<Integer> b = a.map({int i => i + 42});  
arrayShow(intShow).println(b); // {43,44,45}  

EDIT

Check also lambdaj.

Further EDIT

BGGA is entirely optional. It just makes for nicer syntax.


答案 2

Scala is a functional programming language that is fully compatible with Java (runs through the JVM). It offers a beautiful mix of object-oriented and functional techniques along with many improvements over Java in generics and concurrency. Some even say it could replace Java.