Going through the list of Java 8 features, Generalized Target-Type Inference struck me as a particularly interesting, lesser-known gem. It looks as though the Java language designers will ease some of the pain that we've been having with generics in the past (Java 5-7). Let's have a look at their example: class List<E> { static … Continue reading A Lesser-Known Java 8 Feature: Generalized Target-Type Inference
Tag: JDK 8
Subtle Changes in Java 8: Repeatable Annotations
Apart from the "big stuff", related to extension methods, lambda, and the streams API, Java 8 also has a couple of minor, very subtle changes. One of them is the fact that you can now annotate an object several times with the same annotation! An example taken from the tutorial: @Alert(role="Manager") @Alert(role="Administrator") public class UnauthorizedAccessException … Continue reading Subtle Changes in Java 8: Repeatable Annotations
JDK 8: State of the Collections
Here's the latest publication by Brian Goetz, Oracle's project lead for JSR 335, a.k.a. Project Lambda. Here's a nice example showing new collection features, such as "Streams" using method references: List<String> strings = ... int sumOfLengths = strings.stream() .map(String::length) .reduce(0, Integer::plus); Another nice example showing the use of lambda expressions: int sum = shapes.stream() .filter(s … Continue reading JDK 8: State of the Collections