HELP : Math.min.apply(arr); cannot find symbol min

Résolu/Fermé
CORACOC - Modifié le 9 oct. 2019 à 16:14
 CORACOC - 9 oct. 2019 à 16:39
Bonjour,


je ne comprends pas pourquoi ce programme ne fonctionne pas ????
package tableau.random;
import java.util.*;


public class TableauRandom {

  public static void main(String[] args) {
    int totalelem=10,minimum;
    int tableauEntier[] = new int[totalelem];

    for (int i=0 ; i <totalelem ; i++) {
     tableauEntier[i] = (int)(Math.random()*100);
     System.out.print(" "+tableauEntier[i]);
    }

    minimum=Math.min.apply(tableauEntier);
    System.out.println(" ");
    System.out.println("Le nombre minimum compris dans le tableau est : "+minimum);


   }
}

Voici le message d'erreur :

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.lang.Math.min.apply
0 71 21 20 32 81 18 38 20 28 at tableau.random.TableauRandom.main(TableauRandom.java:21)
C:\Users\corac\AppData\Local\NetBeans\Cache\10.0\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\corac\AppData\Local\NetBeans\Cache\10.0\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 0 seconds)

et sur le point d'exclamation rouge en marge : cannot find symbol
symbol : variable min
location : class Math

Quelqu'un peut m'aider ?
Merci


EDIT : Ajout des balises de code

Configuration: Windows / Chrome 77.0.3865.90

3 réponses

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
9 oct. 2019 à 16:21
Bonjour,

Je ne suis pas certain que la methode MAth.min.apply existe en Java.
En Javascript ...oui.... mais en Java... je ne pense pas.

Pour le java :
https://www.javatpoint.com/java-math-min-method
https://stackoverflow.com/questions/51578393/how-to-use-math-min-and-math-max-in-integer-array
0
Ah ok, merci, mais alors je dois faire comment ?
0
jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
9 oct. 2019 à 16:30
Ben... regarder les liens que je t'ai donné serait déjà un bon debut non ?!
0
Désolée, je n'avais pas vu les liens, effectivement j'ai trouvé la solution dans le second lien
Merci beaucoup
0