Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i get Ascii Char for given number

 
Venkat Injapury
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
Is there any method to get Ascii character for given numeric value. I found the Character.getNumericValue(Char ch), It will return Unicode numeric value of given character.I couldn't find the method which will return the Character. your help is appreaciated.
Thanks in advance.
Venkat

 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this is what you want but...
char c = new Character((char)87).charValue();
c contains then 'W' which is the character with ASCII code 87
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Rowan Brownlee
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venkat,
I don't know of a dedicated method as part of the API, but you can try typecasting an integer to a character.
eg. the following loop displays the 'a' to 'z' lowercase.
cheerio
Rowan
public class Test{
public static void main(String args[]){
for(int count = 97; count < 123; count++){
System.out.println((char)count + " " + count);
}
}
}
 
Venkat Injapury
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Valentin Crettaz
Thanks it is working fine.
Thanks
Venkat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic