Compare 01 Flashcards
1
Q
Can you explain the purpose of the compareTo() method?
A
The java string compareTo() method compares the given string with current string lexicographically.
It returns positive number, negative number or 0. It compares strings on the basis of Unicode value of each character in the strings.
2
Q
What does compareTo() method return?
A
It returns positive number, negative number or 0. It compares strings on the basis of Unicode value of each character in the strings.