This question already has an answer here:
- How do I compare strings in Java? 23 answers
My program is becoming terminated when it reaches the point of the if statement I am not sure why. All that I am doing before that point is taking user input. I don't seem to have any errors in the program either. The if statement doesn't have errors either. My question is, what is causing the termination of my program?
if (animal == "cat"){
food = ((10 * animal) + (6.25 * animalinch) - (5 * animalage) +5);
System.out.print("your animal should eat this much" + calories);
}else if (animal == "dog"){
System.out.print("you have a dog");
}
}
Aucun commentaire:
Enregistrer un commentaire