I want to sort city names alphabetically, so I'm using CompareTo to compare city names to sort them. But the CompareTo is giving me an Int and the && isn't liking that. Also, a note - I am not allowed to use arrays.
sFirst = (sCity1.compareToIgnoreCase(sCity2) != 0) && (sCity1.compareToIgnoreCase(sCity3)) ?
sCity1 : sCity2.compareToIgnoreCase(sCity3) ? sCity2 : sCity3;
I've tried putting a > 0 before the && but that didn't seem to do anything and I'm out of ideas.
No, the returning value must be a boolean.
The String#compareToIgnoreCase method is going to return the difference.
Here is a way to evaluate the returning value.
To correct your conditional-statement, you'll need to add these.
Or, use a stream.