Share:- Whatsapp Facebook Facebook

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

How to convert decimal to octal in java?

0 votes
1,387 views
How to convert decimal to octal in java?
asked Oct 15, 2013 in Java by Devendra Singh

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

answered Oct 15, 2013 by Mahendra
...