Skip to content

Commit 9f3c382

Browse files
authored
Merge pull request #151 from bennamrouche/patch-1
Fix incorrect IO.println (java 25+) reference in Java 16+ example
2 parents b854d78 + fe0013b commit 9f3c382

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

content/language/pattern-matching-instanceof.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ modernApproach: "Pattern Variable"
1212
oldCode: |-
1313
if (obj instanceof String) {
1414
String s = (String) obj;
15-
System.out.println(s.length());
15+
int length = s.length();
16+
// do something with 'length'
1617
}
1718
modernCode: |-
1819
if (obj instanceof String s) {
19-
IO.println(s.length());
20+
int length = s.length();
21+
// do something with 'length'
2022
}
2123
summary: "Combine type check and cast in one step with pattern matching."
2224
explanation: "Pattern matching for instanceof eliminates the redundant cast after\

0 commit comments

Comments
 (0)