Home Java Java-get-example Get Ascii Value



Get Ascii Value
Posted on: October 22, 2008 at 12:00 AM
To print ascii value of a character this is the the simplest way to change the type a character.

Get Ascii Value

     

To print ascii value of a character this is the the simplest way to change the type a character. Here in the example given below we will select character from a given string and change their type to integer that will be their ascii value.

Method charAt() of String class is used to select character in the given string on basis of given index value as argument.

public class GetAsciiValue {
public static void main(String[] args) {
String s = "Java";
for (int i=0; i<s.length();i++)
System.out.println("ASCII value of: "+s.charAt(i) + " is:"+ (int)s.charAt(i) );
}

Output will be displayed as:


Download Source Code

Related Tags for Get Ascii Value:
cstringselectintegerprinttypecharasciivaluechangeintthischaractersimpleexamplectetoexamcieilhangpeimfrominasmnttresxaxampsatracisirhallivmplandaractstrsimvasimplestssriringthbelostaluhatpleplprndomo


More Tutorials from this section

Ask Questions?    Discuss: Get Ascii Value   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.