You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Desafio 7 - Encontrar o segundo número maior da lista:
public static int findSecondLargest(List<Integer> list) {
var maxNumber = list.stream().max(Integer::compare).get();
var secondLargest = list.stream()
.filter(n -> n < maxNumber)
.max(Integer::compare).get();
return secondLargest;
}
Activity
fgmarcal commentedon Aug 9, 2024
bom dia, amigo
fiz assim:
GustavoSutanaLima commentedon Aug 25, 2024
Pensei que se você invocasse stream() em uma lista, não era mais possível usar de novo na mesma lista. Estranho... entendi errado
samu-benjamim commentedon Jan 8, 2026
Boa esse deu trabalho.
a minha ficou assim: