-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(collections): 🎸 calculations, translated
Refers: #10
- Loading branch information
1 parent
2bc320e
commit da1b2c7
Showing
5 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,92 @@ | ||
:java-package: src/org/j6toj8/collections | ||
:section-java-package: ../../../{java-package} | ||
|
||
=== Fazendo cálculos e coletando resultados de Streams | ||
=== Perform Calculations and Collecting Streams Results | ||
|
||
.Objetivo | ||
.Objective | ||
-------------------------------------------------- | ||
Perform calculations on Java Streams by using count, max, min, average, and sum methods and save results to a collection by using the collect method and Collector class, including the averagingDouble, groupingBy, joining, partitioningBy methods | ||
- | ||
Realizar cálculos em Streams usando os métodos count, max, min, average, e sum e salvar resultados em uma coleção usando o método collect e a classe Collector, incluindo os métodos averagingDouble, groupingBy, joining, partitioningBy | ||
-------------------------------------------------- | ||
|
||
. É possível pegar o maior ou menor valor, ou a quantidade de elementos da coleção. | ||
. You can get the largest or smallest value, or the number of elements in the collection. | ||
+ | ||
[source,java,indent=0] | ||
.{java-package}/calculations/Collections_MaxMinCount.java | ||
---- | ||
include::{section-java-package}/calculations/Collections_MaxMinCount.java[tag=code] | ||
---- | ||
+ | ||
.Saída no console | ||
.console output | ||
[source,console] | ||
---- | ||
Max: 9 | ||
Min: 1 | ||
Count: 9 | ||
---- | ||
|
||
. É possível pegar a média dos valores da coleção. | ||
. You can take the average of the collection values. | ||
+ | ||
[source,java,indent=0] | ||
.{java-package}/calculations/Collections_AveragingDouble.java | ||
---- | ||
include::{section-java-package}/calculations/Collections_AveragingDouble.java[tag=code] | ||
---- | ||
+ | ||
.Saída no console | ||
.console output | ||
[source,console] | ||
---- | ||
Média: 5.0 | ||
---- | ||
|
||
. É possível agrupar os valores da coleção por uma regra específica. | ||
. You can group collection values by a specific rule. | ||
+ | ||
[source,java,indent=0] | ||
.{java-package}/calculations/Collections_GroupingBy.java | ||
---- | ||
include::{section-java-package}/calculations/Collections_GroupingBy.java[tag=code] | ||
---- | ||
+ | ||
.Saída no console | ||
.console output | ||
[source,console] | ||
---- | ||
Mapa de resto da divisão por 3: {0=[3, 6, 9], 1=[1, 4, 7], 2=[2, 5, 8]} | ||
Map of rest of division by 3: {0=[3, 6, 9], 1=[1, 4, 7], 2=[2, 5, 8]} | ||
---- | ||
|
||
. É possível concatenar os valores da coleção. | ||
. You can concatenate the collection values. | ||
+ | ||
[source,java,indent=0] | ||
.{java-package}/calculations/Collections_Joining.java | ||
---- | ||
include::{section-java-package}/calculations/Collections_Joining.java[tag=code] | ||
---- | ||
+ | ||
.Saída no console | ||
.console output | ||
[source,console] | ||
---- | ||
Junção dos valores como String: 123456789 | ||
Join values as String: 123456789 | ||
---- | ||
|
||
. É possível separar os valores da coleção em um mapa com chaves `true` e `false`, de acordo com uma função lambda. | ||
. You can separate collection values in a map with `true` and `false` keys, according to a lambda function. | ||
+ | ||
[source,java,indent=0] | ||
.{java-package}/calculations/Collections_PartitioningBy.java | ||
---- | ||
include::{section-java-package}/calculations/Collections_PartitioningBy.java[tag=code] | ||
---- | ||
+ | ||
.Saída no console | ||
.console output | ||
[source,console] | ||
---- | ||
Mapa de pares e ímpares: {false=[1, 3, 5, 7, 9], true=[2, 4, 6, 8]} | ||
Even and odd map: {false=[1, 3, 5, 7, 9], true=[2, 4, 6, 8]} | ||
---- | ||
|
||
.References | ||
**** | ||
* Using Streams | ||
+ | ||
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 185). Wiley. Edição do Kindle. | ||
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 185). Wiley. Kindle Edition. | ||
* https://www.baeldung.com/java-8-streams[The Java 8 Stream API Tutorial.] | ||
**** | ||
**** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters