• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
August 10, 2022 |15.5K Views
Java Program to Convert Char to Int
Description
Discussion

In this video, we will write a program to convert a char into int.

Below are the approaches that we have used in this video:

1. Using ASCII value
2. Using String.valueOf()
3. Using Chaacter.getNumericValue()

Method 1: Using ASCII value: In this method, we have used typecasting to get the ASCII value of a character, then subtracted
the ascii value of 0 from it to get the original integer.

Method 2: Using String.valueOf(): To convert from character to String, then using Integer.parseInt() to convert from String to Integer.

Method 3: Using getNumericValue of Character Class. In this method, Character.getNumericValue() converts a character to its numeric value. For example: Character.getNumericValue('3') gets converted to Integer type value 3.

 Java Program to Convert Char to Int:
https://www.geeksforgeeks.org/java-program-to-convert-char-to-int/