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

Java program converts decimal integer to octal number

Use thistoOctalString()method converts decimal to octal. It returns the string representation of the integer parameter (with8The unsigned integer with base 8. The following characters are used as octal digits: 01234567.

First, declare an int value to be converted to octal.

int val = 99;

Now, usingtoOctalString()method converts it to octal.

Integer.toOctalString(val);

Example

public class Demo {
   public static void main(String args[]) {
      int val = 99;
      //Convert to Octal
      System.out.println(Integer.toOctalString(val));
   

Output Result

143