List<String> lineList = new ArrayList<String>();
// less duplication
var lines = new ArrayList<String>();
final var readLines = lines.size();
Merlin Bögershausen / @mboegie
A Project is a collaborative effort to produce a specific artifact, which may be a body of code, or documentation, or some other material.
The goal of Project Amber is to explore and incubate smaller, productivity-oriented Java language features
An enhancement is an effort to design and implement a nontrivial change to the JDK code base or to do some other kind of work whose goals, progress, and result are worth communicating broadly
Local-Variable Type Inference landed in Java 10
List<String> lineList = new ArrayList<String>();
// less duplication
var lines = new ArrayList<String>();
final var readLines = lines.size();
Local-Variable Syntax for Lambda Parameters landed in Java 11
BiConsumer<Consumer<String>, String> sink
= (x, y) -> x.accept(y);
// now with Annotations!
BiConsumer<Consumer<String>, String> safeSink
= (@Nonnull var x, var y) -> x.accept(y);
Multi-line Text Blocks landed in Java 11
String helloWorldResponse = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
Switch Expressions landed in Java 14
int j = switch (day) {// enum Days {MONDAY, …}
case null, MONDAY -> 0;
case TUESDAY -> 1;
default -> {
int k = day.toString().length();
yield k;
}
};
Records landed in Java 16
record Range(int low, int high) {
Range {
if (low > high)
throw new IllegalArgumentException(/*...*/);
}
int lenght() { return high - low; }
}
Records landed in Java 16
record Range(List<Integer> values) {
Range(List<Integer> values) {
this.values = List.copyOf(values);
}
Range(Integer i1, Integer i2) {
this(List.of(i1,i2));
}
}
Sealed Classes landed in Java 17
sealed interface Shape {
sealed class Cornered implements Shape
permits Rectangle, Square{}
final class Weirdo implements Shape {}
}
non-sealed class Rectangle implements Cornered {}
record Square(int h) implements Cornered {}
landed in Java 16
if (o instanceof Triangle t) {
System.out.println("Area: " + t.calculateArea());
} else if (!(o instanceof String str)) {
System.out.println("Not Triangle or String ");
} else {
System.out.println("String value is:" + str);
}
3rd Preview in Java 19
switch (s) {
case Triangle t when t.calculateArea() > 100 ->
System.out.println("Large");
case Triangle t -> System.out.println("Small");
default -> System.out.println("Non-triangle");
}
1st Preview in Java 19
record Point(int x, int y) {}
void printSum(Object o) {
if (o instanceof Point(int x, var y)) {
System.out.println(x+y);
}
}
Lambda Leftovers no target, yet
BiFunction<Integer, String, String> f
= (i, _) -> String.valueOf(i);
class User {
private final String name;
Integer nameLength() = name::length;
}
Jim Laskey and Brian Goetz Sep. 2012
int x = 10, y = 20;
TemplatedString s = "\{x} + \{y} = \{x + y}";
// Concatenation: 10 + 20 = 30
Dukes from OpenJDK: Duke
Amber image from unknown author under CC-BY
Developer Week Logo from DWX Website
Other Images from adesso SE