Attachments:
Answers
Answered by
2
The string compareTo() method compares the given string with current string lexicographically (length wise or character wise). It compares strings on the basis of Unicode value of each character in the strings.
Your code :
"cable".compareTo("cadet") has equal lengths, so it would return -2 as the output because b < d (as d exceeds b by 2, in unicodes as well.)
Answered by
0
Similar questions