String Compareto actual return value
In the Java API on oracles website: "compareTo Returns: "the value 0 if
the argument string is equal to this string; a value less than 0 if this
string is lexicographically less than the string argument; and a value
greater than 0 if this string is lexicographically greater than the string
argument." "
Here is an if statement:
String a = "abd";
String b = "abc";
if(a.compareTo(b) >= 1)
returns true since string a is greater, lexicographically.
My question is, does the compareTo always return a 0, 1, or -1? or does it
return the actual amount that the string is greater than or less than the
string argument.
So in the above if statement, since "abd" is one greater than "abc" is it
returning 1?
No comments:
Post a Comment