 When comparing integers or doubles, we use these symbols for doing the comparison. But we can't use those symbols with strings because strings are objects. Instead, we have to use methods in the string class to compare strings. To compare strings for equality, use the equals method. In this example, the string word1 is assigned Java. Asking if word1.equalsJava returns true. Word1.equalsPython returns false. By the way, when you're doing simple testing, you can use strings directly. You can say Java.equalsJava, which is true, or Python.equalsJava, which returns false. Equality really means character for character equal. If the cases are different, the strings are different. If you want to compare strings for equality while ignoring upper and lower case differences, there's a method for that. Equals ignore case. That takes care of equality. What about comparing for less than and greater than? For that, we need the compareTo method, which returns a negative number, zero, or positive, depending on how the strings are related to one another. Here's a program that lets us see how it works. We read the first string on line 16. And on line 17, we trim off the leading and trailing white space. On line 20, we read the string and trim the white space all in one step. This works because input.nextLine returns a string, which becomes the input to trim in the next step. The official name for this trick is chaining methods, passing the output of one method to the input of the next one. Okay, back to business. Lines 22 through 28 do the comparison and give us the appropriate output. If string one compared to string two gives a number less than zero, that means string one is less than string two. Otherwise, if string one compared to string two gives a number greater than zero, that means string one is greater than string two. And if it's not less than or greater than zero, it must be equal to zero, which means that the two strings are identical. Let's run the program a few times. When the first string is ant and the second is bee, ant is less than bee. If we compare zebra to horse, zebra is greater than horse. Comparing anteater to ant says anteater is greater than ant. So far, so good. Now, let's try this comparison. Cat and compared to capital D dog. The result says that cat is greater than dog. Why is that? Remember that the characters in the string have numeric values. The value of lowercase c is 99, and the value for capital D is 68. 99 is greater than 68, so Java says that cat with a lowercase c is greater than dog with a capital D. Just as equals has equals ignore case. Java also provides a compare to ignore case method. This allows you to compare two strings while ignoring their upper and lowercase differences. And that's how you compare strings in Java.