int a = 1;
char b = (char) a;
System.out.println(b);

will print out the char with Unicode code point 1 (start-of-heading char, which isn't printable; see this table: C0 Controls and Basic Latin, same as ASCII)

int a = '1';
char b = (char) a;
System.out.println(b);

will print out the char with Unicode code point 49 (one corresponding to '1')

If you want to convert a digit (0-9), you can add 48 to it and cast, or something like Character.forDigit(a, 10);.

If you want to convert an int seen as a Unicode code point, you can use Character.toChars(48) for example.

Answer from jh314 on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-int-to-char-conversion
Java Program For Int to Char Conversion - GeeksforGeeks
July 23, 2025 - In Java, char takes 2 bytes (16-bit UTF encoding ), while int takes 4 bytes (32-bit). So, if we want the integer to get converted to a character then we need to typecast because data residing in 4 bytes cannot get into ...
Discussions

converting int -> char
You need to format your number as a string for this to work in the general case, for the specific case of the range of ints from 0-9 you can add them to the char '0' to get the char you want. char digit ='0' + char(I); More on reddit.com
๐ŸŒ r/processing
3
2
December 2, 2023
converting ch to int java
int int1 = (int)ch; should do it, I don't know what part of your code isn't working like it's supposed to you could also try - int a=Character.getNumericValue(ch); More on reddit.com
๐ŸŒ r/CodingHelp
4
3
November 30, 2021
How can I convert a char to int in Java? - Stack Overflow
(I'm new at Java programming) I have for example: char x = '9'; and I need to get the number in the apostrophes, the digit 9 itself. I tried to do the following, char x = 9; int y = (int)(x); bu... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Need help with java converting int to unicode

If the int represents a UTF-16 code unit, just cast it to char.

char c = (char) myInt;

If the int represents a Unicode code point, use Character.toChars()

char[] chars = Character.toChars(myInt);

Note that a Character or char in Java does not represent a Unicode code point or character, rather it represents a UTF-16 code unit.

More on reddit.com
๐ŸŒ r/java
3
0
August 27, 2011
People also ask

Can we convert a char array to String in Java?
Yes, we can convert a char array to a String in Java. We can do this using the constructor of the String class. We need to pass the char array as an argument to the constructor. It will create a String object with the characters from the array. Yes, we can convert a char array to a String in Java. We can do this using the constructor of the String class. We need to pass the char array as an argument to the constructor. It will create a String object with the characters from the array.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ int to char in java
Convert int to char in Java: A Step-by-Step Guide
Can you assign a char to an int in Java?
Yes, you can assign a char value to an int variable in Java because char is implicitly convertible to int. The int variable will store the Unicode value of the corresponding character. Yes, you can assign a char value to an int variable in Java because char is implicitly convertible to int. The int variable will store the Unicode value of the corresponding character.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ int to char in java
Convert int to char in Java: A Step-by-Step Guide
How to take char as input after an integer in Java?
You can use a combination of Scanner class methods to take a char as input after an int in Java. First, read the int using nextInt(), then read the char using next().charAt(0) to capture the first character entered by the user. You can use a combination of Scanner class methods to take a char as input after an int in Java. First, read the int using nextInt() , then read the char using next().charAt(0) to capture the first character entered by the user.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ int to char in java
Convert int to char in Java: A Step-by-Step Guide
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ core java โ€บ convert between int and char in java
Convert Between int and char in Java | Baeldung
January 16, 2024 - Learn how characters are internally represented in Java and how we can convert an int to a char and back.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ int to char in java
Int to Char in Java - Scaler Topics
April 20, 2024 - We can very easily convert int to char using typecasting in Java.
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ examples โ€บ int-to-char-conversion
Java Program to convert int type variables to char
Become a certified Java programmer. Try Programiz PRO! ... class Main { public static void main(String[] args) { // create int variables int num1 = 80; int num2 = 81; // convert int to char // typecasting char a = (char)num1; char b = (char)num2; // print value System.out.println(a); // P System.out.println(b); // Q } }
๐ŸŒ
Upgrad
upgrad.com โ€บ home โ€บ tutorials โ€บ software & tech โ€บ int to char in java
Convert int to char in Java: A Step-by-Step Guide
September 2, 2025 - Your complete guide to converting int to char in Java. Explore different techniques, handle edge cases, and understand the role of ASCII and Unicode with examples.
Find elsewhere
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ examples โ€บ convert-int-type-variables-to-char
Java Program to convert int type variables to char | Vultr Docs
November 25, 2024 - In this article, you will learn how to efficiently convert int type variables to char in Java through practical examples.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-convert-char-to-int
Java Program to Convert Char to Int - GeeksforGeeks
We can convert a Character to its equivalent Integer in different ways, which are covered in this article. ... The char data type is a single 16-bit Unicode character. Its value range lies between '\u0000' (or 0) to '\uffff' (or 65,535 inclusive). The char data type is used to store characters.
Published ย  July 12, 2025
๐ŸŒ
W3Docs
w3docs.com โ€บ java
Convert int to char in java
To convert an int value to a char value in Java, you can use the char type's conversion method, (char).
๐ŸŒ
Reddit
reddit.com โ€บ r/codinghelp โ€บ converting ch to int java
r/CodingHelp on Reddit: converting ch to int java
November 30, 2021 -

i have an assignment where we have to import a file of letters and convert these to ascii numbers where each even number is a colour and each odd is the background. I am struggling on how to convert ch to an int.

heres my code so far

import sheffield.*;
import java.util.Arrays;

public class Assignment2Practice {
       public static void main(String args[]) {
       	   
       	EasyReader fileInput= new EasyReader("duck.txt"); // read in duck file
        String duckText = fileInput.readString(); // convert to string variable
        
        char [][] duckArray = new char [130][130];
       
        for (int 	j =0; (j <130); j++) {
			for (int i=0; (i < 130); i++){
			char ch = duckText.charAt(i); // j[1], v[2]
			int int1= ch;
			
			int int2 = (int) ch;
			
			duckArray[j][i] = ch;
		
			}
	   }
	   System.out.println(Arrays.deepToString(duckArray));
	   }
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2019 โ€บ 04 โ€บ java-int-to-char-conversion
Java int to char conversion with examples
September 11, 2022 - //implicit type casting - automatic conversion char ch = 'A'; // 2 bytes int num = ch; // 2 bytes to 4 bytes /* explicit type casting - no automatic conversion * because converting higher data type to lower data type */ int num = 100; //4 bytes char ch = (char)num; //4 bytes to 2 bytes ยท Lets take an example. In the following example we have an integer number num with the value 70 and we are converting it into a char by doing typecasting. public class JavaExample{ public static void main(String args[]){ //integer number int num = 70; //type casting char ch = (char)num; System.out.println(ch); } }
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ java-program-to-convert-int-to-char
Java program to Convert Int to Char
January 20, 2025 - package NumPrograms; import java.util.Scanner; public class IntToChar1 { private static Scanner sc; public static void main(String[] args) { sc= new Scanner(System.in); System.out.print("Enter Any Integer Value = "); int i = sc.nextInt(); char ch = (char)i; System.out.println("Integer to Character = " + ch); } } We can also convert the integer to a character by adding the character โ€˜0โ€™. The below code use step char type casting and โ€˜0โ€™.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 404152 โ€บ java โ€บ convert-character-integer
convert character to integer (Beginning Java forum at Coderanch)
July 16, 2006 - programming forums Java Mobile ... Other Pie Elite all forums ยท this forum made possible by our volunteer staff, including ... ... Start by casting using (char) and (int)....
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ java-how-to-convert-an-integer-to-a-character-in-a-specific-radix-in-java-413974
How to convert an integer to a character in a specific radix in Java | LabEx
This tutorial will guide you through the process of converting an integer to a character in a specific radix using Java programming language.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java-program-for-int-to-char-conversion
Java Program for Int to Char Conversion
June 19, 2025 - In implicit typecasting, a lower datatype is converted to any other higher datatype automatically by the compiler. When we typecast a higher datatype to a lower data type, then it is called explicit type casting, and it is done manually. In our program, we will use explicit typecasting because the integer range is higher than the character. ... In the Java program given below, we are typecasting an integer value to a character.
๐ŸŒ
Java Code Geeks
examples.javacodegeeks.com โ€บ home โ€บ java development โ€บ core java
Int to char Java Example - Java Code Geeks
August 17, 2020 - We notice that when int value of 65 is converted to char in java, it gets converted to ASCII equivalent and prints value A. Similar observation can be made for 51.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 403716 โ€บ java โ€บ converting-integer-char
converting from integer to char (Beginning Java forum at Coderanch)
June 5, 2006 - It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi ... Well, you can't. Both 'B' and 'b' are converted to 11 by the getNumericValue() method, just for one example. There are about 10 different Unicode characters that are converted to 1 -- you can find out what they are by writing a simple test program.
๐ŸŒ
automateNow
automatenow.io โ€บ home โ€บ how to convert int to char in java
How To Convert int to char in Java | automateNow
May 30, 2024 - In the context of converting an int to a char, youโ€™re essentially instructing the program to interpret the integer value as a character. This is accomplished by using a typecast operator (char) which instructs Java to convert the data that is to the right of that operator to a character value.