Skip to main content

(char)65 ... converting characters to integers

1 reply [Last post]
Nieffed
Offline
Joined: 2012-08-14
Points: 0

Hey guys... first let me preface this by saying I am a total beginner (currently reading Java for dummies) anyways, what I am trying to do is make a simple program that can convert a letter, such as the letter A into its decimal value. I figured out that if I type (char)65 it returns an A which is great, but I can't figure out how to get the exact opposite of that.. that is, converting a letter into its decimal value. I tried (int)A (don't laugh lol) but that didn't work. Any help would be appreciated!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Nieffed
Offline
Joined: 2012-08-14
Points: 0

Never mind! I figured out that what I tried was no laughing matter. However I did learn that there is a difference between using single quote marks and double quote marks. I was typing

out.println((int)"A");

when I should have been typing

out.println((int)'A');

Hopefully this helps another noob like me, haha