Skip to content

Instantly share code, notes, and snippets.

@mloza
Last active November 26, 2021 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mloza/1eb06b31f0d65327babc61ee6cdf2d89 to your computer and use it in GitHub Desktop.
Save mloza/1eb06b31f0d65327babc61ee6cdf2d89 to your computer and use it in GitHub Desktop.
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