aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes problem in understanding operations between chars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "problem in understanding operations between chars" Watch "problem in understanding operations between chars" New topic
Author

problem in understanding operations between chars

M Mistroni
Ranch Hand

Joined: Oct 03, 2005
Posts: 63
hi all,
i m going thru scjp 1.5 exams, i have produced a class that was mentioned in a question
here it is:


here's the output
Comparing:Good vs Bad
a-o=26
Comparing:Good vs Ugly
g-o=32
Comparing:Bad vs Ugly
g-a=37
UglyBadGood----
Ugly
a
o

i can't figure out why 'a' - 'o' will produce 26.. where does that number come from?

anyone could help?

thanks and regards
marco
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

i can't figure out why 'a' - 'o' will produce 26.. where does that number come from?


The number is the difference between the unicode for 'a' and the unicode for 'G'. Note that you formula for the value is different than what you showed on the left of the equals.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in understanding operations between chars