Last active
December 16, 2021 21:26
-
-
Save agiri23/bc62a2af50fc11feca83077efc249de8 to your computer and use it in GitHub Desktop.
pattern matching instanceOf
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
private static void patternMatchingInstanceOf() { | |
Object o = new CountryData("Netherlands","Amsterdam","Europe"); | |
if (o instanceof CountryData countryData) { | |
System.out.println("This capital of Netherlands is " + countryData.capital()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment