Get Ascii Value

In this example you will learn how to print ascii value of a character this is the the simplest way to change the type a character.

Ads

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.

Here is the video tutorial of "How to convert string to ASCII in Java?":

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

Advertisements

Ads
Share on Google+Share on Google+

Get Ascii Value

Posted on: October 22, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Get Ascii Value   View All Comments

Post your Comment


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

good
madhumathi
June 6, 2013
java

this code is useful for me thanks to roseindia.net

Ads

 

Ads