English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program to Convert Octal to Decimal

parseInt()Since the second parameter is the base value, the second parameter is used as8method. TheparseInt()The method has the following two forms.

static int parseInt(String s)
static int parseInt(String s, int radix)

To convert octal to decimal, please use2nd syntax and add the base value as8Because the octal base is8.

Integer.parseInt("25", 8)

The following is an example.

Example

public class Demo {
   public static void main( String args[] ) {
      //Convert to Decimal
      System.out.println(Integer.parseInt("25", 8));
   }
}

Output Result

21