View Single Post
  #2 (permalink)  
Old 01-25-2008, 08:06 PM
roots's Avatar
roots roots is offline
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 286
roots is on a distinguished road
michcio,
Mistake is on int c = a.length();

change it to int c = a.length()-1;

Please refer to javadoc of substring method of String for greater details, In summary it says "@param endIndex the ending index, exclusive."

Just a tip, When you need only one character from string you can use charAt() method of String as well ..

Hope it helps,and dont forget to lookup the String's javadoc.
__________________
dont worry newbie, we got you covered.
Reply With Quote