Home » Tag Archives: Java 8

Tag Archives: Java 8

JUnit: Testing Exceptions with Java 8 and AssertJ 3.0.0

junit-logo

AssertJ 3.0.0 release for Java 8 makes testing exceptions much easier than before. In one of my previous blog post I described how to utilize plain Java 8 to achieve this, but with AssertJ 3.0.0 much of the code I created may be removed. Warning: this blog post contains mostly the code examples.     SUT – System Under Test ...

Read More »

Using Rhino with Java 8

java-logo

Java brings Nashorn as new JavaScript implementation for JSR 223 (javax.scripting). While this is certainly great news (Nashorn is way faster than Rhino by directly generating Java code), it comes with some challenges: Nashorn is not 100% compatible with Rhino. Rhino had some extensions and more or less other interpretations on how to combine the Java world with JavaScript. Therefore ...

Read More »

The JDK 8 SummaryStatistics Classes

java-logo

Three of the new classes introduced in JDK 8 are DoubleSummaryStatistics, IntSummaryStatistics, and LongSummaryStatistics of the java.util package. These classes make quick and easy work of calculating total number of elements, minimum value of elements, maximum value of elements, average value of elements, and the sum of elements in a collection of doubles, integers, or longs. Each class’s class-level Javadoc ...

Read More »

How to FlatMap a JDBC ResultSet with Java 8?

java-interview-questions-answers

You’re not into the functional mood yet? Then the title might not resonate with you – but the article will! Trust me. Essentially, we want this: +------+------+------+ | col1 | col2 | col3 | +------+------+------+ | A | B | C | row 1 | D | E | F | row 2 | G | H | I | ...

Read More »

Java 8 Lambdas in One Line

java-logo

If you understand this line, or better still can write this code you can pretty much say that you have understood the essence of Java 8 Lambdas. Certainly in as much as they can be used with collections. I found this in a recent presentation by Peter Lawrey.  (Definitely worth watching the whole presentation when you have a spare hour.) Anyway ...

Read More »

How to Use Java 8 Streams to Swiftly Replace Elements in a List

java-logo

Imagine you have a list of items: List<String> books = Arrays.asList( "The Holy Cow: The Bovine Testament", "True Hip Hop", "Truth and Existence", "The Big Book of Green Design" ); (Don’t judge me. Books from this random book generator) Now you’d like to create a new list where the third item only is replaced by some new value: List<String> books ...

Read More »

Yet another Java 8 Lamdbas and Streams example

java-logo

I’ve been lagging behind with what Java 8 features exercising concerns, so in this post I will briefly present my initial experience with lambdas and streams. As usual, I will focus on a Podcast class:               package org.codingpedia.learning.java.core; import java.util.Comparator; public class Podcast { int id; String title; String producer; int subscriptionsNumber; /** number of ...

Read More »

Java 8 Lambda Expressions Tutorial

java-logo

Greetings! :) After a few months away I decided to come back in style :). I noticed that one of my previous posts about the new Date/Time API got really popular, so this time I’m going to dedicate this post to another new feature of Java 8: Lambda Expressions. Functional Programming Lambda Expressions are the way by which the Java ...

Read More »

JDK 8 Streams and Grouping

java-logo

I wrote about the powerful features of using JDK 8‘s Streams with Java collections in the post Stream-Powered Collections Functionality in JDK 8. I did not cover use of the groupingBy Collector reduction operation in that post and so address grouping in this post. The examples in this post will demonstrate how to combine Collection-backed Streams with groupingBy Collectors to ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close