chercher le minimum dans tableau de string
bonjour, j'ai un tableau qui contient des chaines de caractères, je veux chercher le minimum dans ce tableau, j'ai écrit ce petit code mais ça marche pas:
Code:
1 2 3 4 5 6 7
| int minVal = Integer.MIN_VALUE;
for(int i = 0; i < listeStrings.length; i++){
int value = Integer.parseInt(listeStrings[i]);
if(value > minVal)
minVal = value;
}
System.out.println(minVal); |
il me génère cette erreur:
Code:
1 2 3 4 5
| Exception in thread "main" java.lang.NumberFormatException: For input string: " 1217183040"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at tableau.main(tableau.java:187) |