Java program to print ASCII value of a particular character


ASCII stands for American Standard Code for Information Interchange. There are 128 standard ASCII codes, each of which can be represented by a 7-digit binary number: 0000000 through 1111111.

If you try to store a character into an integer value it stores the ASCII value of the respective character.

Example

import java.util.Scanner;
public class ASCIIValue {
   public static void main(String args[]){
      System.out.println("Enter a character ::");
      Scanner sc = new Scanner(System.in);
      char ch = sc.next().charAt(0);
      int asciiValue = ch;
      System.out.println("ASCII value of the given character is ::"+asciiValue);
   }
}

Output

Enter a character ::
e
ASCII value of the given character is ::101

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician

Updated on: 13-Mar-2020

415 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements