Home » Tag Archives: Java 8

Tag Archives: Java 8

Guavate: tiny library bridging Guava and Java8

java-logo

Java8 is great and adds some useful abstractions to the JDK that have found popularity in the Java community via the wonderful Guava commons library from Google. Group discussion indicates that there will be a Guava version soon that requires Java 8 and closes the gap between Guava and Java8. However, until such a time, the rest of us using ...

Read More »

Default & Static Methods In Interfaces

java-logo

In our original Java 8 support announcement post we specifically mentioned the lack of streams but completely missed the fact that default/static native interfaces didn’t work. This is now fixed thanks to an alert community member who pointed that out. It seems that these features are turned off by default for retrolambda due to limitations that require a clean build ...

Read More »

How to Generate Customized Java 8 Code with Plugins

java-logo

One thing most programmers hate is to write boilerplate code. Endless hours are spent setting up entity classes and configuring database connections. To avoid this you can let a program like Speedment Open Source generate all this code for you. This makes it easy to get a database project up and running with minimal manual labour, but how do you ...

Read More »

Java 8: Use Smart Streams with Your Database in 2 Minutes

java-logo

Streaming with Speedment When Java 8 finally arrived, some colleges and I started an open-source project to take the whole Java/DB issue one step further by leveraging on Java 8’s stream library, so that database tables could be viewed as pure Java 8 streams. Speedment was born! Wow, now we can do type-safe database applications without having to write SQL-code any ...

Read More »

Java 8: Bye Manual SQL, Hello Speedment!

java-logo

Most applications written in Java require some form of data storage. In small applications this is often realized using a primitive JDBC-connection that is queried using ordinary SQL. Larger systems on the other hand often use an Object Relational Mapping (ORM) frameworks to handle the database communication. There are pro’s and con’s with both of these approaches, but both tend ...

Read More »

Simplifying nested loops with Java 8 Lambdas

java-logo

This is just a quick tip for everyone who often has to work with multi dimensional arrays in Java 8 (or newer). In this case you might often end with code similar to this: float[][] values = ... for (int i = 0; i < values.length; i++) {   for (int k = 0; k < values[i].length; k++) {     float value = values[i][k];     // do something with i, k and value   } } If you are lucky you can replace the loops with for-each loops. However, often the indices are required for ...

Read More »

Java 8 Deferred Invocation with Java Util Logging

java-logo

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

java-logo

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

java-logo

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 »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials