0

How would I get the strings "part1" to properly compare to "findF","findPLUS", and "findMINUS?" Currently it runs without any errors but it does not properly do the actions inside of the if then statement.

output is "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);  
    }       
}
jww
  • 97,681
  • 90
  • 411
  • 885
Wafan
  • 1

0 Answers0