File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
I agree. Here's the link:
subject: can you increment letters?
It's not a secret anymore!