Skip to content

Commit de27189

Browse files
committed
feat(streams): 🎸 using streams, translated
Refers: #7
1 parent 6ffff54 commit de27189

31 files changed

+246
-250
lines changed

book/05-java-streams/sections/01-using-streams.asc

Lines changed: 148 additions & 151 deletions
Large diffs are not rendered by default.

src/org/j6toj8/streams/usingstreams/Streams_ArraysStream.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ public class Streams_ArraysStream {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
// Criação de um array comum de Strings
9+
// Create a common string array
1010
String[] array = new String[] { "A", "B", "C" };
11-
// Criação de um Stream a partir do array e, para
12-
// cada elemento, o método println é chamado.
11+
// Create a stream from the array and, for each element, the println method is called.
1312
Arrays.stream(array).forEach(System.out::println);
1413
// end::code[]
1514
}

src/org/j6toj8/streams/usingstreams/Streams_Distinct.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ public class Streams_Distinct {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
// Criação de um array comum de Strings
9+
// Create a common string array
1010
String[] array = new String[] { "A", "B", "C", "A", "B", "F" };
1111

1212
Arrays.stream(array)
13-
.distinct() // ignora elementos repetidos
13+
.distinct() // ignore repeated elements
1414
.forEach(System.out::println);
1515
// end::code[]
1616
}

src/org/j6toj8/streams/usingstreams/Streams_Filter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ public class Streams_Filter {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
IntStream.range(0, 4) // stream de 0 a 3
10-
.filter(e -> e % 2 == 0) // limita a números pares (resto da divisão por 2 é 0)
11-
.forEach(System.out::println); // imprime os elementos
9+
IntStream.range(0, 4) // stream from 0 to 3
10+
.filter(e -> e % 2 == 0) // limited to even numbers (rest of division by 2 is 0)
11+
.forEach(System.out::println); // prints the elements
1212
// end::code[]
1313
}
1414
}

src/org/j6toj8/streams/usingstreams/Streams_FindFirstAny.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ public class Streams_FindFirstAny {
77

88
public static void main(String[] args) {
99
// tag::code[]
10-
Optional<Integer> findFirst = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
11-
.findFirst(); // pega o primeiro número do Stream
10+
Optional<Integer> findFirst = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
11+
.findFirst(); // get the first stream number
1212
System.out.println("First: " + findFirst.get());
1313

14-
Optional<Integer> findAny = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
15-
.findAny(); // pega qualquer número do Stream
14+
Optional<Integer> findAny = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
15+
.findAny(); // get any number from the stream
1616
System.out.println("Any: " + findAny.get());
1717
// end::code[]
1818
}

src/org/j6toj8/streams/usingstreams/Streams_FlatMap.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ public class Streams_FlatMap {
77

88
public static void main(String[] args) {
99
// tag::code[]
10-
// Criação de 3 arrays distintos
10+
// Create 3 distinct arrays
1111
String[] array1 = new String[] { "A", "B", "C" };
1212
String[] array2 = new String[] { "D", "E", "F" };
1313
String[] array3 = new String[] { "G", "H", "I" };
1414

15-
Stream.of(array1, array2, array3) // criação de um Stream de Arrays
16-
.flatMap(a -> Arrays.stream(a)) // transforma os dados de cada array em um único fluxo de dados
17-
.forEach(System.out::println); // imprime os elementos
15+
Stream.of(array1, array2, array3) // create a stream of arrays
16+
.flatMap(a -> Arrays.stream(a)) // transform data from each array into a single data stream
17+
.forEach(System.out::println); // prints the elements
1818
// end::code[]
1919
}
2020
}

src/org/j6toj8/streams/usingstreams/Streams_Limit.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ public class Streams_Limit {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
IntStream.range(0, 4) // stream de 0 a 3
10-
.limit(2) // limita a 2 elementos
11-
.forEach(System.out::println); // imprime os elementos
9+
IntStream.range(0, 4) // stream from 0 to 3
10+
.limit(2) // limited to 2 elements
11+
.forEach(System.out::println); // prints the elements
1212
// end::code[]
1313
}
1414
}

src/org/j6toj8/streams/usingstreams/Streams_Map.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ public class Streams_Map {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
IntStream.range(0, 4) // stream de 0 a 3
10-
.map(e -> e * 2) // multiplica os elementos por 2
11-
.forEach(System.out::println); // imprime os elementos
9+
IntStream.range(0, 4) // stream from 0 to 3
10+
.map(e -> e * 2) // multiply the elements by 2
11+
.forEach(System.out::println); // prints the elements
1212
// end::code[]
1313
}
1414
}

src/org/j6toj8/streams/usingstreams/Streams_Match.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ public class Streams_Match {
66

77
public static void main(String[] args) {
88
// tag::code[]
9-
boolean anyMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
10-
.anyMatch(e -> e > 5); // vefifica se algum elemento é maior que 5
9+
boolean anyMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
10+
.anyMatch(e -> e > 5); // check if any element is greater than 5
1111
System.out.println("anyMatch: " + anyMatch);
1212

13-
boolean allMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
14-
.allMatch(e -> e > 5); // vefifica se TODOS os elementos são maiores que 5
13+
boolean allMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
14+
.allMatch(e -> e > 5); // check if ALL elements are greater than 5
1515
System.out.println("allMatch: " + allMatch);
1616

17-
boolean noneMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
18-
.noneMatch(e -> e > 5); // vefifica NENHUM elemento é maior que 5
17+
boolean noneMatch = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
18+
.noneMatch(e -> e > 5); // checks that NO element is greater than 5
1919
System.out.println("noneMatch: " + noneMatch);
2020

2121
// end::code[]

src/org/j6toj8/streams/usingstreams/Streams_MaxMinCount.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ public class Streams_MaxMinCount {
88

99
public static void main(String[] args) {
1010
// tag::code[]
11-
Optional<Integer> max = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
12-
.max(Comparator.naturalOrder()); // pega o maior número do Stream
11+
Optional<Integer> max = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
12+
.max(Comparator.naturalOrder()); // get the greatest stream number
1313
System.out.println("Max: " + max.get());
1414

15-
Optional<Integer> min = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
16-
.min(Comparator.naturalOrder()); // pega o menor número do Stream
15+
Optional<Integer> min = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
16+
.min(Comparator.naturalOrder()); // get the smallest stream number
1717
System.out.println("Min: " + min.get());
1818

19-
long count = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream de vários Integer
20-
.count(); // pega a quantidade de elementos do Stream
19+
long count = Stream.of(7, 2, 1, 8, 4, 9, 2, 8) // stream from multiple Integer
20+
.count(); // get the number of stream elements
2121
System.out.println("Count: " + count);
2222
// end::code[]
2323
}

0 commit comments

Comments
 (0)