Hi, when you compare s5 to s6, it checks if s5 is smaller than equal to or greater than s6. and it returns an integer value according to the result.
here as it compares s5 to s6 it finds that s5 contains "AMIT" and s6 contains "amit". so it starts comparing both string character by character
as there is a differenct of -32 (A-a==> 65-97==>-32 (unicode values)) it prints -32
similarly it does the same thing for s6.compareTo(s5).
but when you compare s6 to s6 itself, it finds no differnence. that is the strings are equal. hence prints 0;
Hope it helps Correct if am wrong
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Joined: Aug 31, 2005
does compareTo applies only for char or for everything