Java Program to Convert int to char - The Coding Shala

Home >> Java Programs >> Convert int to char

 Hey there, welcome back to another post. In this post, we are going to learn how to convert int to char in Java.

Java Program to Convert int to char

We can convert int to char using explicit type-casting. Here, the size of int is 4 bytes and char's size is 1 byte so we need explicit type-casting.

Java Program: 


public class Main {

    public static void main(String[] args) {
        int num = 97;

        // explicit type casting because higher to lower data type
        // int(4 bytes) to char(1 byte)
        // char ch = num;  -> this will give error
        char ch = (char) num;
        System.out.println("Converted char is: " + ch);


Converted char is: a

Other Posts You May Like
Please leave a comment below if you like this post or found some errors, it will help me to improve my content.


Popular Posts from this Blog

Shell Script to find sum, product and average of given numbers - The Coding Shala

Single Number 3 LeetCode Solution - The Coding Shala

LeetCode - Number of Good Pairs Solution - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Java Method Overloading - The Coding Shala