Stepik is going to update the Java version in Autumn and HS content team started writing content for Java 15 features. However they aren't sure whether the new content will have errors produced by linters cause they may not know about the new features.
There are some features from new versions of Java we'd like you to check:
Text blocks
String htmlWithJava13 = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
Switch expressions
String result = switch(new Random().nextInt(5)){
case 1 -> "a";
case 2 -> "b";
default -> "unknown";
};
Records
record Person(String name, String surname) {
public Person {
if (name == null || surname == null) {
throw new RuntimeException("Name and surname is mandatory!");
}
}
}
Pattern Matching For InstanceOf
if (obj instanceof String s) {
System.out.println(s.contains("hello"));
}
Sealed Classes
public sealed interface Drivable permits Vehicle {
void accelerate();
}
public abstract non-sealed class Vehicle implements Drivable {
public abstract void configure();
}
the link
https://medium.com/blue-harvest-tech-blog/what-happened-to-java-after-8-java-15-and-the-future-8a005edcc013