Java Convert short to Octal String

Tags: short Octal

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);
    }
}
The output as below.
short value: 128
octal value: 200

Happy Coding 😊

Java Convert Octal String to short

Java Convert Octal String to Integer

Java Convert Integer to Octal String