This week's book giveaway is in the Kotlin forum.We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# problem in understanding operations between chars

M Mistroni
Ranch Hand
Posts: 64
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
a-o=26
Comparing:Good vs Ugly
g-o=32
g-a=37
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
Posts: 23283
125
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

 It is sorta covered in the JavaRanch Style Guide.