Laws
04-20-2006, 05:18 PM
If I have the character value h how can I get the number it is in the alphabet, i.e. i'm looking to output 8
Thanks
Nick
Thanks
Nick
![]() | View Full Version : Java Problem Laws 04-20-2006, 05:18 PM If I have the character value h how can I get the number it is in the alphabet, i.e. i'm looking to output 8 Thanks Nick stdunbar 04-20-2006, 05:40 PM Assuming that your characters are lower case English characters (a-z) just do: char myChar = 'h'; System.out.println( myChar - 'a' + 1); a -> 1 b -> 2 and so on. |