Hi, could any one tell about the following code. String s5 = "AMIT"; String s6 = "amit"; System.out.println(s5.compareTo(s6)); System.out.println(s6.compareTo(s5)); System.out.println(s6.compareTo(s6)); it would print -32 32 0 how we calculate -32 and 32
bindu john
Greenhorn
Joined: Oct 04, 2000
Posts: 15
posted
0
Hi In the first case "AMIT" is compared with "amit".In the ASCII table 'A' got a value 65[decimal] and 'a' got value 97. return type of compareTo is int which is 65-97 ie -32. reverse is the case for second case Bindu [This message has been edited by bindu john (edited October 17, 2000).]