Skip to content

Instantly share code, notes, and snippets.

@wkdalsgh192
Created September 8, 2021 01:43
Show Gist options
  • Save wkdalsgh192/4060272ce74aca3cac4cc83fe3cac363 to your computer and use it in GitHub Desktop.
Save wkdalsgh192/4060272ce74aca3cac4cc83fe3cac363 to your computer and use it in GitHub Desktop.
public void managingStateAndAction() {
List<Pay> pays = Arrays.asList(
new Pay(PAYPAL, 1000),
new Pay(VISA, 2000),
new Pay(MASTER_CARD, 3000),
new Pay(UNION_CARD, 5000)
);
Long totalSum = pays.stream().filter(pay -> pay.getPayType().equals(VISA)).mapToLong(Pay::getAmount).sum();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment