I wrote this method, and I am 99% sure it should set color to "green" when I enter "GrEeN" but for some reason it does not, and sets color to "white". Does anyone know why?
public void setColor(String c)
{
String c2 = c.toLowerCase();
if (c2 == "red" || c2 == "blue" || c2 == "green" || c2 == "white")
color = c2;
else
color = "white";
}
Aucun commentaire:
Enregistrer un commentaire