Home » Tag Archives: Java 8 (page 5)

Tag Archives: Java 8

Common SQL Clauses and Their Equivalents in Java 8 Streams

Functional programming allows for quasi-declarative programming in a general purpose language. By using powerful fluent APIs like Java 8’s Stream API, or jOOλ’s sequential Stream extension Seq or more sophisticated libraries like javaslang or functionaljava, we can express data transformation algorithms in an extremely concise way. Compare Mario Fusco’s imperative and functional version of the same algorithm: Imperative vs. Functional ...

Read More »

What is the fastest Garbage Collector in Java 8?

OpenJDK 8 has several Garbage Collector algorithms, such as Parallel GC, CMS and G1. Which one is the fastest? What will happen if the default GC changes from Parallel GC in Java 8 to G1 in Java 9 (as currently proposed)? Let’s benchmark it. Benchmark methodology Run the same code 6 times with a different VM argument (-XX:+UseSerialGC, -XX:+UseParallelGC, -XX:+UseConcMarkSweepGC, ...

Read More »

Java 8’s Method References Put Further Restrictions on Overloading

Method overloading has always been a topic with mixed feelings. We’ve blogged about it and the caveats that it introduces a couple of times: You Will Regret Applying Overloading with Lambdas! Keeping things DRY: Method overloading Why Everyone Hates Operator Overloading API Designers, be Careful There are two main reasons why overloading is useful: To allow for defaulted arguments To ...

Read More »

Using Java 8 CompletableFuture and Rx-Java Observable

I wanted to explore a simple scatter-gather scenario using Java 8 CompletableFuture and using Rx-Java Observable. The scenario is simple – Spawn about 10 tasks, each returning a string, and ultimately collect the results into a list. Sequential A sequential version of this would be the following: public void testSequentialScatterGather() throws Exception { List<String> list = IntStream.range(0, 10) .boxed() .map(this::generateTask) ...

Read More »

Java SE 8 new features tour: Processing Collections with Streams API

Cleaner, readable, and powerful coding with Java SE 8 Streams….. In this article of the “Java SE 8 new features tour” series, we will deep dig into explanation, and exploring the code, on how to traversing collections with streams Creating streams from collections and arrays, Aggregating stream values. In the previous article “Traversing, filtering, processing collection, & methods enhancements with ...

Read More »

Java performance tutorial – How fast are the Java 8 streams?

In this JAX Magazine sneak preview, JAX London speaker Angelika Langer answers the most important question for anyone using Java streams: are they really faster? Java 8 came with a major addition to the JDK collection framework, namely the stream API. Similar to collections, streams represent sequences of elements. Collections support operations such as add(), remove(), and contains() that work ...

Read More »

Casting In Java 8 (And Beyond?)

Casting an instance to a type reeks of bad design. Still, there are situations where there is no other choice. The ability to do this has hence been part of Java since day one. I think Java 8 created a need to slightly improve this ancient technique. Static Casting The most common way to cast in Java is as follows: ...

Read More »

Functional Programming in Java 8 with Javaslang

We’re very happy to announce a guest post on the jOOQ Blog written by Daniel Dietrich, Senior Software Engineer at HSH Nordbank, husband and father of three. He currently creates a pricing framework for financial products as project lead and lead developer. Besides his work, he is interested in programming languages, efficient algorithms and data structures. Daniel wrote the short ...

Read More »