Java Program to Print the Character of given ASCII Value

Get a ASCII value from user (0 to 255) and display the corresponding character

Sample Input 1:

75

Sample Output 1:

K

Sample Input 2:

97

Sample Output 2:

a

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

public class Hello { public static void main(String args[]) { //Write your code here } }

Program or Solution

				
			
					
//To Print The Character Of Given Ascii Value...

import java.util.*;

class Program
{
  public static void main(String args[])
  {
      int val;
     char ascii;
     Scanner sc=new Scanner(System.in);

     System.out.println("Enter The Value:");
     val=sc.nextInt();

     ascii=(char)val;

     System.out.println("The Output Is:"+ascii);
  }
}
			
				
			

Program Explanation

converting an integer to character using (char) returns the ascii value of the number.

Comments