Skip to content

Implementação da Classe SomaNumeros  #97

Description

@RicarlosJunior

Percebe no seu codigo que quando você esta dentro do laço o seu teste e se numero e >= (Maior ou iguala) e nao > (Maior) tem um motivo para adicionar o = (Igual) ?

public int encontrarMaiorNumero() {
int maiorNumero = Integer.MIN_VALUE;
if (!numeros.isEmpty()) {
for (Integer numero : numeros) {
if (numero >= maiorNumero) {
maiorNumero = numero;
}
}
return maiorNumero;
} else {
throw new RuntimeException("A lista está vazia!");
}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions