Java convert char to short
In this Java core tutorial we learn how to convert a char value into a short value in Java programming language.
How to convert char to short in Java
In Java, with a given char value we can convert it to short by casting the char variable into a short variable as the following example Java program.
ConvertCharToShortExample1.java
public class ConvertCharToShortExample1 {
public static void main(String... args) {
char charValue = 'A';
short shortValue = (short)charValue;
System.out.println("char value: " + charValue);
System.out.println("short value: " + shortValue);
}
}
char value: A
short value: 65
Happy Coding 😊
Related Articles
Java convert short to BigInteger