Skip to content

Commit c7dd38c

Browse files
committed
feat(collections): 🎸 diamond, translated
Refers: #10
1 parent 9b60c68 commit c7dd38c

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
:java-package: src/org/j6toj8/collections
22
:section-java-package: ../../../{java-package}
33

4-
=== Diamond Operator (Operador Diamante)
4+
=== Diamond Operator
55

6-
.Objetivo
6+
.Objective
77
--------------------------------------------------
88
Develop code that uses diamond with generic declarations
9-
-
10-
Desenvolver código que usa o diamond (diamante) com declarações de generics
119
--------------------------------------------------
1210

13-
O Diamond Operator (ou Operador Diamante) foi criado no Java 7 para remover código desnecessário ao declarar classes que usam `Generics` (ou tipos genéricos). Abaixo um exemplo que é possível omitir o tipo de algumas classes utilizando o _Diamond Operator_.
11+
Diamond Operator was created in Java 7 to remove unnecessary code when declaring classes that use `Generics` (or generic types). Below is an example that you can omit the type of some classes using _Diamond Operator_.
1412

1513
[source,java,indent=0]
1614
.{java-package}/diamond/Collections_Diamond.java
1715
----
1816
include::{section-java-package}/diamond/Collections_Diamond.java[tag=code]
1917
----
2018

19+
.References
2120
****
2221
2322
* Using the Diamond Operator
2423
+
25-
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 596). Wiley. Edição do Kindle.
24+
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 596). Wiley. Kindle Edition.
2625
2726
* https://www.baeldung.com/java-diamond-operator[Guide to the Diamond Operator in Java.]
2827
29-
****
28+
****

src/org/j6toj8/collections/diamond/Collections_Diamond.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ public class Collections_Diamond {
99

1010
public static void main(String[] args) {
1111
// tag::code[]
12-
List<String> l1 = new ArrayList<String>(); // sem diamond
13-
List<String> l2 = new ArrayList<>(); // com diamond
14-
List<> l3 = new ArrayList<String>(); // NÃO COMPILA - diamond só pode ser utilizado do lado direito
12+
List<String> l1 = new ArrayList<String>(); // without diamond
13+
List<String> l2 = new ArrayList<>(); // with diamond
14+
List<> l3 = new ArrayList<String>(); // NOT COMPILING - diamond can only be used on the right side
1515

16-
Map<String, String> m1 = new HashMap<String, String>(); // sem diamond
17-
Map<String, String> m2 = new HashMap<>(); // com diamond
18-
Map<> m3 = new HashMap<String, String>(); // NÃO COMPILA - diamond só do lado direito
16+
Map<String, String> m1 = new HashMap<String, String>(); // without diamond
17+
Map<String, String> m2 = new HashMap<>(); // with diamond
18+
Map<> m3 = new HashMap<String, String>(); // NOT COMPILING - diamond can only be used on the right side
1919

20-
Map<List<String>, List<String>> m4 = new HashMap<List<String>, List<String>>(); // sem diamond
21-
Map<List<String>, List<String>> m5 = new HashMap<>(); // com diamond
22-
Map<List<String>, List<String>> m6 = new HashMap<<>,<>>(); // NÃO COMPILA - a única sintaxe válida é <>
23-
Map<List<String>, List<String>> m7 = new HashMap<List<String>, <>>(); // NÃO COMPILA - a única sintaxe válida é <>
20+
Map<List<String>, List<String>> m4 = new HashMap<List<String>, List<String>>(); // without diamond
21+
Map<List<String>, List<String>> m5 = new HashMap<>(); // with diamond
22+
Map<List<String>, List<String>> m6 = new HashMap<<>,<>>(); // NOT COMPILING - the only valid syntax is <>
23+
Map<List<String>, List<String>> m7 = new HashMap<List<String>, <>>(); // NOT COMPILING - the only valid syntax is <>
2424

25-
Map<Map<List<String>, List<String>>, Map<List<String>, List<String>>> m8 = new HashMap<>(); // com diamond
25+
Map<Map<List<String>, List<String>>, Map<List<String>, List<String>>> m8 = new HashMap<>(); // with diamond
2626

27-
Map<> m9 = new HashMap<>(); // NÃO COMPILA - é necessário informar o tipo do lado esquerdo
27+
Map<> m9 = new HashMap<>(); // NOT COMPILING - it's necessary to inform the type on the left side
2828
// end::code[]
2929
}
3030

0 commit comments

Comments
 (0)