Results 1 to 4 of 4
  1. #1
    akabir77 is offline Member
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default How to get the next character

    I have a stupid question.

    I have a method that gets a character. And I need to increase it by one (so if a comes in, i need make it b, if g comes in I have to make it h).

    Is there a easy way to do this? i tried with inChr++ but that doesn't work...

    Java Code:
    public char increaseChar(char inChr){
    
     return inChr= inChr++;
    
    }

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default Re: How to get the next character

    Java Code:
    return ++inChr;

  3. #3
    akabir77 is offline Member
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default Re: How to get the next character

    lol found the solution. posting for other newbies like me.

    Java Code:
    public char increaseChar(char inChr){
     
    int temp = Character.getNumericValue(inChr);
    
     temp = temp + 88;
    
     return (char) temp;
     
    }

  4. #4
    akabir77 is offline Member
    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Default Re: How to get the next character

    Quote Originally Posted by camickr View Post
    Java Code:
    return ++inChr;
    ops didn't see this. this works better

Similar Threads

  1. ^ Escape character
    By GaBuG in forum Advanced Java
    Replies: 3
    Last Post: 12-31-2010, 01:04 AM
  2. Character Count
    By drucey in forum New To Java
    Replies: 8
    Last Post: 11-22-2010, 08:02 PM
  3. getting each character from keyboard
    By Sreejesh25 in forum Advanced Java
    Replies: 6
    Last Post: 03-05-2010, 07:12 PM
  4. Read from a certain character to a certain character
    By blackstormattack in forum New To Java
    Replies: 0
    Last Post: 03-16-2009, 11:36 AM
  5. reading text character by character
    By bugger in forum New To Java
    Replies: 2
    Last Post: 11-09-2007, 08:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •