How is -32 printed? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1
22nd Jun 2021, 4:30 AM
alagammai uma
alagammai uma - avatar
2 Respuestas
+ 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'...
22nd Jun 2021, 4:51 AM
visph
visph - avatar
+ 2
visph thank you
22nd Jun 2021, 4:53 AM
alagammai uma
alagammai uma - avatar