Bonjour,

Je ne comprends pas pourquoi mon programme ne donne rien au lancement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package tp1;
 
public abstract class CaltoNew {
    public static double calculate(String arg){
        String nombre1="";
        double resultat=0;
        String nombre2="";
        String operation=null;
        String tab[]=arg.split(" ");
 
        for(String value : tab){
            if(!CheckIp.isNumeric(value)){
                operation = new String(value);
            }
            else{
                if(nombre1.isEmpty()){
                    nombre1 = new String(value);
                }
                else{
                    nombre2 = new String(value);
                }
 
            }
            if(operation == "+"){
                resultat = resultat + Integer.parseInt(nombre1) + Integer.parseInt(nombre2);
            }
            if(operation == "-"){                
                resultat = resultat + Integer.parseInt(nombre1) - Integer.parseInt(nombre2);
            }
            if(operation == "/"){
                resultat = resultat + Integer.parseInt(nombre1) / Integer.parseInt(nombre2);
            }
            if(operation == "*"){
                resultat = resultat + Integer.parseInt(nombre1) * Integer.parseInt(nombre2);
            }
        }
        return resultat;
    }
 
    public static void main(String[] argu){
        String op = "17 + 3 * 5";
        System.out.println(calculate(op));
    }
}
La fonction isNumeric permet de vérifier si l'élément est bien un nombre.

Quelqu'un saurait-il m'indiquer d'où peut venir le problème ?

Merci d'avance pour votre aide.