+ 1
How is -32 printed?
Java strings https://code.sololearn.com/c7IYlyvIwRwF/?ref=app
2 Antworten
+ 6
from java doc:
"In this case, compareTo returns the difference of the two character values at position k >in the two string -- that is, the value:
this.charAt(k)-anotherString.charAt(k)
If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case, compareTo returns the difference of the lengths of the strings -- that is, the value:
this.length()-anotherString.length()"
https://docs.oracle.com/javase/6/docs/api/java/lang/String.html#compareTo%28java.lang.String%29
in your code case example that's the difference between char codes of 'A' and 'a'...
+ 2
visph thank you