Java Convert Integer to Octal String

Tags: Integer Octal

In this Java core tutorial we learn how to convert an Integer value to a octal digit String in Java programming language.

How to convert Integer to Octal String in Java

In Java, with a given Integer value we can use the Integer.toOctalString(int i) static method to convert it to a String in octal base 8 as the Java code below.

ConvertIntegerToOctalExample.java

public class ConvertIntegerToOctalExample {
    public static void main(String... args) {
        int intValue = 1024;

        // Convert Integer to Octal String
        String octalString = Integer.toOctalString(intValue);

        System.out.println("int value: " + intValue);
        System.out.println("octal value: " + octalString);
    }
}
The output as below.
int value: 1024
octal value: 2000

Happy Coding 😊

Java Convert Octal String to short

Java Convert short to Octal String

Java Convert Octal String to Integer