Solved

numebrs to alphabets  in java

Posted on 2007-04-04
5
183 Views
Last Modified: 2010-03-31
hi guys

If i have series of numbers say
1
2
3
4
5
..... and so on

how can i convert that to char format like

a
b
c
d
e
f
..... and so on



so basically
a corresponds to 1
b corresponds to 2
c corresponds to 3
and
so on ...

any one who can provide java code to do that will be greatly appreciated
thanks very much
J

0
Comment
Question by:jaggernat
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 18853992
char alpha = (char)(i + 'a' - 1);

(where 'i' is your integer)
0
 
LVL 12

Expert Comment

by:keyurkarnik
ID: 18866865
You need to take the ascii value of character 'a' which is 97 and then do this :

char val = char(num + 96)

OR for Capital alphabets :

char val = char(num + 64)
0
 
LVL 12

Expert Comment

by:keyurkarnik
ID: 18866886
replace num by your integer value
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now