Java, Java8, Java21, Java17, Migration.
System.out.println(city); } } static void printCityWithPatternMatching(Object obj) { if (obj instanceof Address(String city, String apartment)) { System.out.println(city); } } In the printCityWithoutPatternMatching method, prior to Java 21, accessing the city required first checking if the object