Java Convert Long to Octal String
In this Java core tutorial we learn how to convert a long value into octal String in Java programming language.
How to convert Long to Octal String in Java
In Java, with a given long value we can use the Long.toOctalString(long i) static method to convert it to an octal String as the following example Java code.
ConvertLongToOctalExample.java
public class ConvertLongToOctalExample {
public static void main(String... args) {
long longValue = 999999;
// Convert Long to Octal String
String octalString = Long.toOctalString(longValue);
System.out.println("Long value: " + longValue);
System.out.println("Octal value: " + octalString);
}
}
Long value: 999999
Octal value: 3641077
Happy Coding 😊
Related Articles
Java Convert Long to Hexadecimal String
Java Convert Hexadecimal String to Long