AbacusUtil Docs | Download | Javadoc | FAQ | Community

Functional Programming in Java 8

Here are some very good tutorials and a simple sample:
Understanding Java 8 Stream Performance from Maurice Naftalin
When to use parallel streams and Java Doc

Extra features supported by AbacusUtil:

  • Stream is supported for primitive type except boolean: CharStream, ByteStream, ShortStream, IntStream, LongStream, FloatStream, DoubleStream and Stream.
  • More convenient APIs are provided by: Collectors and Stream
  • Integrated with different data structures: DataSet, Multimap, Multiset and primitive list.
  • Faster Java8 stream implementation for array/collection. Here is the performance test result: stream_performance_test_result.txt by below code:

  • With the support of Lambda/Stream and DataSet, AbacusUtil provides a set of VERY POWERFUL APIs to process/analyze data.

    Stream.of("abc", "123", "ab123").filter(str -> str.startsWith("a")).forEach(N::println);
    // abc
    // ab123
    List<String> strs = N.asList("Hello Java", "I LIKE Functional Programming");
    // average length of words in the strings.
    Stream.of(strs).flatMap2(str -> str.split(" ")).collect(Collectors.averagingDouble(str -> str.length()));
    // 5.833333333333333
    // count the characters in upper case.
    Stream.of(strs).flatMapToChar(str -> Stream.from(str.toCharArray())).filter(ch -> Character.isUpperCase(ch)).count();
    // 9