Compare a character in a string with a letter?
问题 I want to compare a character in a string with the letter "R". So I want to check if the character on the position i in the string is a "R", a "L" or a "F". This is my code, but it doesn't word... I'm a Java beginner and really happy about every idea to improve my code and makes it work. for (int i = s.length()-2; i >= 0; i--){ if (s.charAt(i) == "R"){ s = s + "L";} else if (s.charAt(i) == L){ s = s + "R";} else {s = s + "F";} // s = s + s.charAt(i); }//for By the way, the complete exercise