This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 20029
    
  44

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: problem in understanding operations between chars
 
It's not a secret anymore!