Skip to content

Instantly share code, notes, and snippets.

@mloza
Last active Nov 26, 2021
Embed
What would you like to do?
Przykłady kodu do wpisu o nowych możliwościach Javy 17 znajdującego się pod adresem: https://blog.mloza.pl/java-17-nowa-wersja-z-rozszerzonym-wsparciem-lts/
switch(i) {
case null -> System.out.println("It's a null!");
case Integer s && s < 10 -> System.out.println("It's a number smaller than 10");
case String s && s.length() < 20 -> System.out.println("Short string");
case String s -> System.out.println("Long String");
default -> System.out.println("It's something else");
}
package pl.mloza;
public sealed class Shape
permits Circle, Square, Rectangle {
}
final class Circle extends Shape {}
non-sealed class Square extends Shape {}
final class Rectangle extends Shape {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment