我如何获得字符串" part1"正确地比较" findF"," findPLUS"和" findMINUS?"目前它运行时没有任何错误,但它没有正确执行if then语句中的操作。
输出是" F - F +"
public void arrayHolder(){
String compare = ",F,-,F,+";
for(int i=0;i<=(compare.length()/2);i++){
String[] index = compare.split(",");
String part1 = index[i];
String findF = new String("F");
String findPLUS = new String("+");
String findMINUS = new String("-");
if(part1 == findF){
m.forward(25);
}else if(part1 == findPLUS){
m.turnLeft();
}else if(part1 == findMINUS){
m.turnRight();
}
System.out.println(part1);
}
}