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