Java Convert Octal String to Long
In this Java core tutorial we learn how to convert an octal String into long value in Java programming language.
How to convert Octal String to Long in Java
In Java, with a given octal String we can use the Long.decode(String nm) static method to convert it to a long value as the following example Java code.
ConvertOctalToLongExample.java
public class ConvertOctalToLongExample {
public static void main(String... args) {
String octalValue1 = "0246000"; // String start with 0
// Convert Octal String to Long
long longValue1 = Long.decode(octalValue1);
System.out.println("Octal value: " + octalValue1);
System.out.println("Long value: " + longValue1);
}
}
Octal value: 0246000
Long value: 84992
Happy Coding 😊
Related Articles
Java Convert Long to Hexadecimal String
Java Convert Hexadecimal String to Long