You Can Try This:

public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    System.out.println("Testing Scanner, write something: ");
    String testi = scan.nextLine();
    char[] ascii1 = testi.toCharArray();

    for(char ch:ascii1){
        System.out.println((int)ch+"  ");
    }


    System.out.println("Testing Scanner, write something: ");
    String testi2 = scan.nextLine();
    char[] ascii2 = testi2.toCharArray();

    for(char ch:ascii2){
        System.out.println((int)ch+"  ");
    }

  scan.close();
}
Answer from AsSiDe on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › print-given-sentence-equivalent-ascii-form
Print given sentence into its equivalent ASCII form - GeeksforGeeks
ASCII (American Standard Code for ... in the string ... Input : hello, world! Output : ASCII Sentence: 104101108108111443211911111410810033Input : GeeksforGeeks Output : ASCII Sentence: 7110110110711510211111471101101107115 ... To complete the task, we need to convert each character ...
Published   February 8, 2024
Discussions

Quick help on converting String to Ascii then back to String.
you can do math with the char primitive, so you can use string.charAt(index) to get the individual character and do +1 to it, i.e. 'a' + 1 is 'b'. You can't put it back into the original string, however as strings are immutable. Either create a new string or use StringBuilder. edit: Also, you will have to handle 'Z' or 'z' differently, obviously. More on reddit.com
🌐 r/javahelp
2
3
May 11, 2016
How to convert string to an ascii? - Oracle Forums
Hi,everyone! I want to convert the string "����" to ascii , for example: "����" -> \u4e2d\u56fd The "->" means the "����" will be converted to "\u... More on forums.oracle.com
🌐 forums.oracle.com
September 4, 2007
string - Convert character to ASCII numeric value in java - Stack Overflow
So there can be characters in a Java string that do not belong to ASCII. Such characters do not have an ASCII numeric value, so asking how to get the ASCII numeric value of a Java character is unanswerable. But why do you want to do this anyway? What are you going to do with the value? If you want the numeric value so you can convert ... More on stackoverflow.com
🌐 stackoverflow.com
Character to ASCII
Get the char value of the first letter from the String. Cast the char to an int. Character Docs Unicode Character Representations The char data type (and therefore the value that a Character object encapsulates) are based on the original Unicode specification, which defined characters as fixed-width 16-bit entities. The Unicode Standard has since been changed to allow for characters whose representation requires more than 16 bits. The range of legal code points is now U+0000 to U+10FFFF, known as Unicode scalar value. (Refer to the definition of the U+n notation in the Unicode Standard.) The set of characters from U+0000 to U+FFFF is sometimes referred to as the Basic Multilingual Plane (BMP). Characters whose code points are greater than U+FFFF are called supplementary characters. The Java platform uses the UTF-16 representation in char arrays and in the String and StringBuffer classes. In this representation, supplementary characters are represented as a pair of char values, the first from the high-surrogates range, (\uD800-\uDBFF), the second from the low-surrogates range (\uDC00-\uDFFF). A char value, therefore, represents Basic Multilingual Plane (BMP) code points, including the surrogate code points, or code units of the UTF-16 encoding. An int value represents all Unicode code points, including supplementary code points. The lower (least significant) 21 bits of int are used to represent Unicode code points and the upper (most significant) 11 bits must be zero. Unless otherwise specified, the behavior with respect to supplementary characters and surrogate char values is as follows: The methods that only accept a char value cannot support supplementary characters. They treat char values from the surrogate ranges as undefined characters. For example, Character.isLetter('\uD840') returns false, even though this specific value if followed by any low-surrogate value in a string would represent a letter. The methods that accept an int value support all Unicode characters, including supplementary characters. For example, Character.isLetter(0x2F81A) returns true because the code point value represents a letter (a CJK ideograph). More on reddit.com
🌐 r/javahelp
7
3
March 22, 2021
🌐
Blogger
javarevisited.blogspot.com › 2015 › 07 › how-to-convert-string-or-char-to-ascii-example.html
How to convert String or char to ASCII values in Java - Example Tutorial
June 26, 2025 - Here is our Java program, which combines all the ways we have seen to convert String and character to their respective ASCII values. You can also use the same technique to convert String to other encoding formats e.g. ISO-8859-X (1-7) , UTF-8, UTF-16BE, UTF-16LE.
🌐
Coderanch
coderanch.com › t › 591584 › java › Converting-string-ASCII-values
Converting string to ASCII values and back (Beginning Java forum at Coderanch)
September 3, 2012 - Guillaume Jourdan wrote:Hi, You ... does not make much sense! First you convert a String using the ASCII encoding into a byte array, and then assume this byte array to be the platform-default encoded version of a String and fetch it....
🌐
MojoAuth
mojoauth.com › character-encoding-decoding › ascii-encoding--java
ASCII Encoding : Java | Encoding Solutions Across Programming Languages
In Java, encoding text using ASCII is straightforward. The getBytes() method of the String class can be used to convert a string into an array of bytes that represent the ASCII values of the characters.
🌐
Baeldung
baeldung.com › home › java › get the ascii value of a character in java
Get the ASCII Value of a Character in Java | Baeldung
February 5, 2025 - If our char is in a String, we can use the charAt() method to retrieve it: String str = "abc"; char c = str.charAt(0); System.out.println((int) c); Simply put, we can convert an ASCII value to its equivalent char by casting:
Find elsewhere
🌐
Medium
medium.com › @AlexanderObregon › converting-characters-to-ascii-values-in-java-053b0f7d8334
Converting Characters to ASCII Values in Java | Medium
October 20, 2025 - Java chose Unicode from the start, which is why its char type is larger than the traditional 8-bit byte. The overlap comes in the first 128 values of Unicode, which are identical to ASCII. That means a cast of 'G' still produces 71, exactly as it would in an ASCII-only environment. Everything beyond that range reflects the Unicode standard instead. public class UnicodeCheck { public static void main(String[] args) { char normal = 'G'; char extended = 'é'; System.out.println(normal + " numeric value -> " + (int) normal); System.out.println(extended + " numeric value -> " + (int) extended); } }
🌐
Oracle
forums.oracle.com › ords › apexds › post › how-to-convert-string-to-an-ascii-3167
How to convert string to an ascii? - Oracle Forums
September 4, 2007 - Hi,everyone! I want to convert the string "����" to ascii , for example: "����" -> \u4e2d\u56fd The "->" means the "����" will be converted to "\u...
🌐
Vultr Docs
docs.vultr.com › java › examples › find-ascii-value-of-a-character
Java Program to Find ASCII Value of a character | Vultr Docs
September 27, 2024 - Convert a character directly to its corresponding ASCII value using type casting. Here’s how to implement this: java Copy · public class AsciiValue { public static void main(String[] args) { char ch = 'a'; // Character to find the ASCII value int ascii = ch; // Implicit conversion System.out.println("The ASCII value of " + ch + " is: " + ascii); } } Explain Code ·
🌐
BeginnersBook
beginnersbook.com › 2015 › 05 › java-ascii-to-string-conversion
Java – ASCII to String conversion
September 11, 2022 - In this tutorial we will learn how to convert ASCII values to a String.
🌐
Programiz
programiz.com › java-programming › examples › ascii-value-character
Java Program to Find ASCII Value of a character
Become a certified Java programmer. Try Programiz PRO! ... public class AsciiValue { public static void main(String[] args) { char ch = 'a'; int ascii = ch; // You can also cast char to int int castAscii = (int) ch; System.out.println("The ASCII value of " + ch + " is: " + ascii); System.out.println("The ASCII value of " + ch + " is: " + castAscii); } }
🌐
TutorialsPoint
tutorialspoint.com › java-program-to-convert-ascii-code-to-string
Java Program to convert ASCII code to String
To convert ASCII to string, use the toString() method. Using this method will return the associated character.Let’s say we have the following int value, which works as ASCII for us.int asciiVal = 89;Now, use the toString() method.String str ...
🌐
Coderanch
coderanch.com › t › 665058 › java › Converting-ASCII-code-characters
Converting ASCII code to characters (Java in General forum at Coderanch)
April 28, 2016 - For example it should convert the following ASCII codes: 76, 101, 116 to the characters Let Any help would be much appreciated. ... How do the values come in? If they're numbers then just stick them in a char[]. If they're Strings (eg "76") then parse them and then stuck them in a char[].
🌐
Online String Tools
onlinestringtools.com › convert-ascii-to-string
Convert ASCII Code to a String – Online String Tools
Quickly convert a string to ASCII codes. ... Quickly convert ASCII codes to a string.
🌐
PrepBytes
prepbytes.com › home › java › how to convert int to string in java
How to Convert int to string In Java
July 18, 2023 - In this example, the for loop iterates over each character of the text string. The char is cast to an int using (int) character, which gives the ASCII value of the character. The ASCII value is then printed for each character in the string.
🌐
Java2Blog
java2blog.com › home › core java › string › character › convert character to ascii numeric value in java
Convert Character to ASCII Numeric Value in Java - Java2Blog
May 4, 2021 - You can simply use index with toCharArray() to get ASCII value of character in the String. Here is an example: ... You can convert String to byte array using getBytes(StandardCharsets.US_ASCII) and this byte array will contain character’s ...
🌐
RapidTables
rapidtables.com › convert › number › hex-to-ascii.html
Hex to String | Hex to ASCII Converter
Enter hex code bytes with any prefix / postfix / delimiter and press the Convert button (e.g. 45 78 61 6d 70 6C 65 21): * ASCII text encoding uses fixed 1 byte for each character.