Java Convert short to Octal String
In this Java core tutorial we learn how to convert a short value to a octal digit String in Java programming language.
How to convert short to octal String in Java
In Java, with a given short value we can use the Integer.toOctalString(int i) static method to convert it to String in octal base 8 as the following Java program.
ConvertShortToOctalExample1.java
public class ConvertShortToOctalExample1 {
public static void main(String... args) {
short shortValue = 128;
// Convert short value to octal String
String octalString = Integer.toOctalString(shortValue);
System.out.println("short value: " + shortValue);
System.out.println("octal value: " + octalString);
}
}
short value: 128
octal value: 200
Happy Coding 😊
Related Articles
Java Convert Octal String to short