
250 CHAPTER 5 Flow of Control,Part 1: Selection
In Example 5.12, we define three similar Strings: title1 (Green Pastures),
title2 (Green Pastures II), and title3 (green pastures). When we compare
title1, Green Pastures, to title3, green pastures, using the equals method (line
14), the result is false, because the Strings do not match in case. When we
perform the same comparison using the equalsIgnoreCase method (line
20), however, the result is true, because except for capitalization, these two
Strings are identical in character sequence and length.
Using the compareTo method (line 34), Green Pastures evaluates to less
than Green Pastures II. Although ...