I have a very simple question that I really can't understand.
I have a method that takes a string and determines what the first character of the string is, and then returns it.
public String deterFirstChar(String value){
String keyValue;
char res;
res = value.charAt(0);
keyValue = Character.toString(res);
if (keyValue == "C"){
return keyValue;
} else if (keyValue == "G") {
return keyValue;
}
System.out.println("Error: Wrong keyParam");
return "F";
}
However, intstead of returning, for an example keyValue = C, it skipps the if statement and returns "F" when I know for sure that keyValue is "C".
Why is this occurring?