In this example we will show the method to convert a number to octal in Java.
Source Code
package com.beginner.examples;
public class Num2Octal {
public static void main(String[] args) {
int num = 17;
System.out.println(Integer.toOctalString(num)); // convert a number to octal
}
}
Output:
21