Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to change a character in a string in java with ascii

// From Char to Ascii
char character = 'a';    
int ascii = (int) character;

// From Ascii to Char
int ascii = 65;
char character = (char) ascii;
Comment

how to change a character in a string in java with ascii

// Very simple. Just cast your char as an int.

char character = 'a';    
int ascii = (int) character;

//In your case, you need to get the specific Character from the String first and then cast it.

char character = name.charAt(0); // This gives the character 'a'
int ascii = (int) character; // ascii is now 97.

//Though cast is not required explicitly, but its improves readability.

int ascii = character; // Even this will do the trick.
Comment

PREVIOUS NEXT
Code Example
Java :: recursion examples java 
Java :: java php object 
Java :: java string.format system.currenttimemillis 
Java :: how to compare strings java 
Java :: find last element in array in java 
Java :: string to int error 
Java :: jdk 15 download brew 
Java :: integer to binary java 
Java :: not equal java 
Java :: reverse number in java 
Java :: java check if property exists in class 
Java :: java singleton 
Java :: Java Regex : 4 Letters followed by 2 Integers 
Java :: binary search java 
Java :: Loop in singly linked list 
Java :: split with multiple condition in java 
Java :: convert Date to LocalDate via Instant 
Java :: switch statement java 
Java :: how to get index of arraylist in java 
Java :: java map keyset to list 
Java :: parcourir un string java 
Java :: reverse loop in java 
Java :: interface extending interface in java 
Java :: remove tableview separator lines in javafx 
Java :: change text size java 
Java :: maximum integer in array java 
Java :: finding length of arrays in java 
Java :: type variable java 
Java :: thread priorities in java 
Java :: how to check when edittext clicked android 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =