Skip to content

Commit 80b8136

Browse files
Copilotbrunoborges
andcommitted
Use Java 5-compatible generics example
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent a59925f commit 80b8136

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

content/language/raw-collections-to-generics.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ oldCode: |-
1515
1616
String name = (String) names.get(0);
1717
modernCode: |-
18-
List<String> names = new ArrayList<>();
18+
List<String> names = new ArrayList();
1919
names.add("Duke");
2020
21-
String name = names.getFirst();
21+
String name = names.get(0);
2222
summary: "Replace raw collection types and retrieval casts with compile-time generic type safety."
2323
explanation: "Raw collections accept arbitrary object types and defer type errors until a cast executes.\
2424
\ Generic type arguments let the compiler validate writes and reads, remove casts, improve IDE assistance,\

proof/language/RawCollectionsToGenerics.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
/// Proof: raw-collections-to-generics
66
/// Source: content/language/raw-collections-to-generics.yaml
77
void main() {
8-
List<String> names = new ArrayList<>();
8+
List<String> names = new ArrayList();
99
names.add("Duke");
1010

11-
String name = names.getFirst();
11+
String name = names.get(0);
1212
}

0 commit comments

Comments
 (0)