Java Convert Integer to Octal String
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);
}
}
int value: 1024
octal value: 2000
Happy Coding 😊
Related Articles
Java Convert Octal String to short