-
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