Below, I have two objects, (Tom wel) and (Tom sue). How would an if/else statement look if I wanted to compare the two strings inside of the objects. In this case, when love is the first string in each object, I want the code to read, "The same". When one object contains love as the first string and the other says something else, I want it to print, "hate". How can I compare the two first strings in each object with each other?
Tom wel;
wel= new Tom("love","blush");
Tom sue;
sue = new Tom("love","god");
if (/*what goes in here*/) {
System.out.println("The same");
} else {
System.out.println("hate");
}
Aucun commentaire:
Enregistrer un commentaire