Home Java Java-get-example Get Ascii Value
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Get Ascii Value

Advertisement
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

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 22, 2008

Ask Questions?    Discuss: Get Ascii Value   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Rajeev
August 21, 2011
good

good
madhumathi
June 6, 2013
java

this code is useful for me thanks to roseindia.net
DMCA.com