String buffer = "c";
char ch = buffer.charAt(0);
System.out.println((int)ch);

This should do it.

Answer from Ankur on Stack Overflow
🌐
YouTube
youtube.com › mahran al-zyoud
Java characters and getting their equivalent decimal values - YouTube
In this video, we convert between a Unicode character and its equivalent decimal value and vice versa.
Published   April 21, 2020
Views   196
Discussions

How do I get the decimal value of a unicode character in Java? - Stack Overflow
I need a programmatic way to get the decimal value of each character in a String, so that I can encode them as HTML entities, for example: ... There's no such thing as a "UTF-8 character" or "decimal encoding". "UTF-8" is an encoding, and "decimal" is a number base. ... You're right. I've revised the question ... Cheers. I don't know Java... More on stackoverflow.com
🌐 stackoverflow.com
Java printing String characters as unicode decimal value.
You can use String.charAt() to get chars out of a string. You can get the unicode value of a char by simply casting a char to an int. For example: String hello = "Hello Reddit!"; int unicodeValue = (int)hello.charAt(0); System.out.println(unicodeValue); //prints 72, unicode value of H More on reddit.com
🌐 r/learnprogramming
13
1
September 20, 2018
java - How to convert char to decimal using an ascii table? - Stack Overflow
I'm working on a java program to convert a 4 digit binary number to decimal. I need to enter the binary as a String, convert to a char, and then to a decimal. I cannot use something like: int deci... More on stackoverflow.com
🌐 stackoverflow.com
February 3, 2017
Convert special characters into decimal equivalents in java - Stack Overflow
You just need to fetch the integer value of the character as mentioned in How do I get the decimal value of a unicode character in Java?. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Javatpoint
javatpoint.com › java-char-to-int
Java char to int - javatpoint
Java int to char · Java String to boolean · Java boolean to String · Date to Timestamp · Timestamp to Date · Binary to Decimal · Decimal to Binary · Hex to Decimal · Decimal to Hex · Octal to Decimal · Java Convert Decimal to Octal · JDBC Introduction ·
🌐
Javatpoint
javatpoint.com › java-int-to-char
Java int to char - javatpoint
Java int to char · Java String to boolean · Java boolean to String · Date to Timestamp · Timestamp to Date · Binary to Decimal · Decimal to Binary · Hex to Decimal · Decimal to Hex · Octal to Decimal · Java Convert Decimal to Octal · JDBC Introduction ·
🌐
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 - If when we add ‘0’ we get the char, then conversely by subtracting the ‘0’ decimal value, we should get the int: @Test public void givenAChar_whenSubtracting0_thenExpectedNumericType() { char c = '7'; int n = c - '0'; assertEquals(7, n); } This indeed works, but there are better and simpler ways to do it.
🌐
Reddit
reddit.com › r/learnprogramming › java printing string characters as unicode decimal value.
r/learnprogramming on Reddit: Java printing String characters as unicode decimal value.
September 20, 2018 -

I put a word into a string array and now I'm trying to print the letters as their unicode decimal values.

Scanner so = new Scanner(System.in);

String word = so.nextLine();

String[] chars = word.split("");

System.out.println(chars[0]);

So the code should print out the first letter of the word, but I want to convert it to its unicode decimal value. I've been scouring the internet for the last hour but nothing is working. does anyone have any answers? thanks!

Find elsewhere
🌐
CopyProgramming
copyprogramming.com › howto › java-casting-a-char-to-decimal-code-example
Java: Example of Converting a Character to Decimal Code in Java
August 23, 2023 - Java Program to convert int type variables to char, Here, 10 and 16 are radix values for decimal and hexadecimal numbers respectively. That is, if the int value is between 0 to 9, we use 10 as radix value, if the int value is between 0 to 15, we use 16, and so on.
🌐
Delft Stack
delftstack.com › home › howto › java › how to convert int to char in java
How to Convert Int to Char in Java | Delft Stack
February 2, 2024 - To get the actual char value, we can also use Character.forDigit() method to convert int to char in Java. It determines the character representation for a specific digit in the specified radix.
🌐
Coderanch
coderanch.com › t › 404152 › java › convert-character-integer
convert character to integer (Beginning Java forum at Coderanch)
July 16, 2006 - do not store a 5 anywhere; you store 53 or more precisely 0000_0000_0011_0101. You don't convert chars to integers at all; chars always are integers (see this Java™ Language Specification section).
🌐
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 - Convert int to char in Java with precision. Explore effective methods to transform numeric values into characters, enhancing versatility in your Java programming endeavors Java Convert int to char
🌐
RoseIndia
roseindia.net › java › java-conversion › convert-decimal-to-ascii.shtml
Convert Decimal To Character
Here, define class named ?DecimalToChar? for java component. This program takes a decimal value. Type casting (char) d ) is done to convert the decimal into the corresponding character..
🌐
Reddit
reddit.com › r/javahelp › need help converting a char value to integer
r/javahelp on Reddit: Need help converting a char value to integer
November 6, 2022 -

I am trying to convert a char value to its corresponding integer for example '0x21A6' is the same as integer 6. Here is my code:

public String toIntegersString(char[] arrows){

//an empty string to store the converted integer values

String ints = " ";

for (int j = 0; j< arrows.length; j ++) {

//the method I used to convert to integers

int nums = Character.getNumericValue(arrows[j]);

// converting from integer to String

ints = ints + String.valueOf(nums) + " ";

}

return ints;

}

Then my main in my main method this is what I have:

ArrowSymbol arrs = new ArrowSymbol();

//This is to just be able to connect to my helper class

char[] arrows = { 0x21A6};

System.out.println(arrs.toIntegersString(arrows));

My problem is when I do this, it prints out -1 meaning it is out of bounds. Please assist

Top answer
1 of 5
4
Converting 0x21A6 from hexadecimal (base 16) to decimal (base 10) gives 8614 which is quite a way off from 6. Where are you getting your hexadecimal values from or how are you generating them? If you want you can just cast the char value to int since char types in java are backed by integer values they are compatible (though not directly equatable). char cDec = 8614; char cHex = 0x21A6; System.out.println("Dec char is: " + cDec); System.out.println("Hex char is: " + cHex); System.out.println("Dec cast back to int: " + ((int) cDec)); System.out.println("Hex cast back to int: " + ((int) cHex));
2 of 5
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › character_digit.htm
Java - Character digit() Method
The following example shows the usage of Java Character digit(char ch, int radix) method. In this example, we've initialized two char variables with hexadecimal values and then using digit(), we're getting numeric value corresponding to 2 and 10 radix and result is printed.
🌐
Programiz
programiz.com › java-programming › examples › int-to-char-conversion
Java Program to convert int type variables to char
We have used the forDigit() method converts the specified int value into char value. Here, 10 and 16 are radix values for decimal and hexadecimal numbers respectively. That is, if the int value is between 0 to 9, we use 10 as radix value, if the int value is between 0 to 15, we use 16, and so on.
🌐
Scaler
scaler.com › home › topics › int to char in java
Int to Char in Java - Scaler Topics
April 20, 2024 - Hence, this method is useful for integers that have more than one digit. ... As shown by the output, integer 56 has been converted to string "56". The forDigit() method in Java is used to convert a digit into a character in a specific radix.