Home » Tag Archives: Java 8 (page 2)

Tag Archives: Java 8

Java 8 Deferred Invocation with Java Util Logging

In the blog post Better Performing Non-Logging Logger Calls in Log4j2, I looked at approaches one can use in Log4j 2 to reduce or avoid invocation of methods in log statements that, based on the specified log level, are not actually logged at all. As part of this discussion, I covered Log4j 2‘s support for Java 8-based deferred execution using ...

Read More »

Java 8: Declare Private and Protected Methods in Interfaces

When Java 8 was introduced, we could use default methods in interfaces. The main driver for this feature was to allow expansion of an interface while retaining backward compatibility for older interface versions. One example is the introduction of the stream() method in the existing Collection classes. Sometimes, when we want to introduce several default methods, they may share some ...

Read More »

Put Your Java 8 Method References to Work

Method References As we all know by now, we can use Method References, like String::isEmpty, in Java 8 to reference a method that is being used when we, for example, stream over elements. Take a look at this code snippet: Stream.of("A", "", "B").filter(Stream::isEmpty).count(); which will produce the result 1 (because there is just one empty element in the stream). But, ...

Read More »

Grouping, transforming and reduction with Java 8

1. Introduction In this previous post, I wrote about how we can group collections of objects with streams and grouping. This is useful but does not cover specific use cases. For example, sometimes we do not only need to group things but also transform the result into a more appropriate object. In this post, we will learn how to apply ...

Read More »

(Ab)using Java 8 FunctionalInterfaces as Local Methods

If you’re programming in more advanced languages like Scala or Ceylon, or even JavaScript, “nested functions” or “local functions” are a very common idiom to you. For instance, you’ll write things like fibonacci functions as such: def f() = { def g() = "a string!" g() + "– says g" } (Question from Stack Overflow by Aaron Yodaiken) The f() ...

Read More »

Parsing Java 8 Streams Into SQL

When Java 8 was released and people began streaming over all kinds of stuff, it didn’t take long before they started imagining how great it would be if you could work with your databases in the same way. Essentially relational databases are made up of huge chunks of data organized in table-like structures. These structures are ideal for filtering and ...

Read More »

Streaming over Maps with Java 8

In this article I will show you how Speedment Open Source stream efficiently over standard Java maps, expanding the Stream interface into something called a MapStream! This addition will make it easier to keep your streams concrete and readable even in complex scenarios. Hopefully this will allow you to keep streaming without prematurely collecting the result. One of the largest ...

Read More »

Using Oracle AQ via Java 8 Streams

java-interview-questions-answers

One of the most awesome features of the Oracle database is Oracle AQ: Oracle Database Advanced Queuing. The AQ API implements a full fledged, transactional messaging system directly in the database. In a classic architecture where the database is at the center of your system, with multiple applications (some of which written in Java, others written in Perl or PL/SQL, ...

Read More »