Java Convert Octal String to Integer
In this Java core tutorial we learn how to convert an octal String into Integer value in Java programming language.
How to convert octal String to Integer in Java
In Java, with given String in octal number format we can use the Integer.decode(String nm) static method to convert it to an Integer value as the following Java code.
ConvertOctalToIntegerExample.java
public class ConvertOctalToIntegerExample {
public static void main(String... args) {
String octalValue1 = "0200";
String octalValue2 = "0400";
// Convert Octal String to Integer
int intValue1 = Integer.decode(octalValue1);
int intValue2 = Integer.decode(octalValue2);
System.out.println("octalValue1: " + octalValue1);
System.out.println("intValue1: " + intValue1);
System.out.println("\noctalValue2: " + octalValue2);
System.out.println("intValue2: " + intValue2);
}
}
octalValue1: 0200
intValue1: 128
octalValue2: 0400
intValue2: 256
Happy Coding 😊
Related Articles
Java Convert Octal String to short