We can convert decimal to octal in java using Integer.toOctalString() method or custom logic.
Java Decimal to Octal conversion: Integer.toOctalString()
The Integer.toOctalString() method converts decimal to octal string. The signature of toOctalString() method is given below:
public static String toOctalString(int decimal)
Let's see the simple example of converting decimal to octal in java.
Output:
Java Decimal to Octal conversion: Custom Logic
We can convert decimal to octal in java using custom logic.
Output: