This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes can you increment letters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can you increment letters?" Watch "can you increment letters?" New topic

can you increment letters?

Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
I have a String which is the letter A is there anyway i can dynamically chane it to B ?
obviously A + 1 = A1
but is there something similar for letters?
thank you
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
If it's just letters you want why not use char??
The code below prints out j and then k.

Hope that helps,
Terry Doyle

Raising Flares debut album 'Ignition' out now

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Remember, Strings are immutable, so there is nothing that you can do to dynamically or explicitly change the value of a string.
The suggestion to use chars is a good one. Remember that chars are primitive in Java.

Brian Hoff
Sun Certified Programmer for the Java� 2 Platform
Have you checked out Aspose?
subject: can you increment letters?
jQuery in Action, 3rd edition