
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert decimal integer to octal in Java
To convert decimal to octal, use the toOctalString() method in Java. Let’s say the following is our decimal.
int decInt = 21;
To convert it to Octal, we need to use the toOctalString() method.
String myOct = Integer.toOctalString(decInt);
The following is the complete example that converts decimal to octal.
Example
public class Demo { public static void main(String []args) { int decInt = 21; System.out.println("Decimal Integer = "+decInt); String myOct = Integer.toOctalString(decInt); System.out.println("Octal = "+myOct); } }
Output
Decimal Integer = 21 Octal = 25
- Related Questions & Answers
- Java Program to convert decimal integer to octal number
- Java Program to convert Decimal to Octal
- Java Program to convert integer to octal
- Convert octal number to decimal number in Java
- How to Convert Decimal to Octal?
- Java program to convert decimal number to octal value
- Java program to convert float decimal to Octal number
- Java Program to convert octal number to decimal number
- Convert decimal integer to hexadecimal number in Java
- C# program to convert decimal to Octal number
- C++ Program to convert Decimal Numbers to Octal
- How to convert a Decimal to Octal using C#?
- Python program to convert float decimal to octal number
- Java Program to convert decimal integer to hexadecimal number
- How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
Advertisements