Home » Tag Archives: Java 8

Tag Archives: Java 8

Common SQL Clauses and Their Equivalents in Java 8 Streams

java-logo

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?

java-logo

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

java-logo

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

java-logo

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

java-logo

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?

java-logo

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?)

java-logo

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

java-logo

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 »

Cheating with Exceptions – Java 8 Lambdas

java-logo

Cheating with Exceptions – Java 8 Lambdas Leaving aside the religious debate about Checked vs Runtime exceptions, there are times where due to poorly constructed libraries, dealing with checked examples can drive you insane. Consider this snippet of code which you might want to write: public void createTempFileForKey(String key) { Map<String, File> tempFiles = new ConcurrentHashMap<>(); //does not compile because ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.