dimanche 19 juin 2016

Why this java code doesn't work?

This code is logically correct.. but it's not working...

int operatorIndex;
String str = "25+45";

if((operatorIndex = str.indexOf(str.indexOf("+") < str.indexOf("-") ? "+": "-")) != -1){
   System.out.println("works!");
}
System.out.println(operatorIndex); //-1

Aucun commentaire:

Enregistrer un commentaire