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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 62
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: 16695
    
  19

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: problem in understanding operations between chars
 
Similar Threads
Compare() - from Master Exam
Dount in K&B exam question
comparator question ..why oh why?
Comparator Doubt
Sorting and Comparators