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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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