Share:- Whatsapp Facebook Facebook

------------------------------------- Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

0 votes
1.4k views
How to convert decimal to octal in java?
in Java by

1 Answer

0 votes

package com.convert;

public class ConvertDecimalToOctal {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int decimalNum = 9;
        String octal = getDecimalToOctal(decimalNum);
        System.out.println("Decimal : " + decimalNum);
        System.out.println("Octal : " + octal);
    }

    private static String getDecimalToOctal(int decimalNum) {
        String octal = Integer.toOctalString(decimalNum);
        return octal;
    }

}
 

Output:

Decimal : 9
Octal : 11

by
...