Java

jonne - 28 janv. 2018 à 02:56
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 - 28 janv. 2018 à 11:06
Bonjour,
comment je peut tire la valeur maximale des valeurs stockes dans un tableau
merci

1 réponse

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 127
28 janv. 2018 à 11:06
Bonjour,

La méthode
max()
est faite pour ça.
https://docs.oracle.com/javase/9/docs/api/java/util/stream/IntStream.html#max--

Exemple :
int[] tab = { 1, 4, 7, 9, 6, 3, 8, 5, 2 };
int max = Arrays.stream(tab).max().get();
0
Rejoignez-nous