I have a method to set state but when I initialize in main method one false and one true statement I am not seeing the change I should be inside of the output. Could someone explain why this is because if state is declared I would assume it would go through the if statement but the state never gets altered from the declared variable in main method?
public void setState(String state)
{
this.state = state;
if(state == "MA" || state == "PA")
{
this.state = state;
}
else
{
this.state = "Invalid Entry";
}
}
Aucun commentaire:
Enregistrer un commentaire