Changes in Java13
Both text blocks and switch expressions still are preview features!
Text Blocks
New way to use multiline strings. They start with 3 "
and a newline.
String jsonBlock = """
{
greeting: "Hello",
audience: "World"
}
"""
Both text blocks and switch expressions still are preview features!
New way to use multiline strings. They start with 3 "
and a newline.
String jsonBlock = """
{
greeting: "Hello",
audience: "World"
}
"""
It has been revamped to act as an expression. It removes the usage of break
.
switch(day) {
case SATURDAY, SUNDAY -> System.out.println(1);
case TUESDAY, FRIDAY -> System.out.println(2);
case THURSDAY, MONDAY -> System.out.println(3);
case WEDNESDAY -> System.out.println(4);
}
This is a list of the changes at Java’s API I found interesting or that I may use frecuently. Not all the changes from Java9, 10 & 11 are listed here.
It stands for Java Shell. It’s used to easily execute and test any Java construction like a class, interface, enum, etc.
The way we deploy Java-Based applications using jars has a lot of limitations & drawbacks. Some of these are: The JRE & JDK are too big; JAR files are too big to use in small devices and applications; There’s no strong encapsulation, public is open to everyone.
The new Module System introduces new features to avoid all this. More information here.
(I’ll use Lists as an example in this file, but this is valid for Maps and Sets too)
Until Java8 we could use Collections.unmodifiableList()
to achieve this, but this is really verbose. Now we can do the same with
List inmutableList = List.of("bla", "ble", "bli");