- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to convert integer to octal
To convert integer to octal in Java, use the Integer.toOctalString() method.
Let’s say the following is our integer.
int val = 768;
Convert the above integer to octal.
Integer.toOctalString(val)
The following is the final example.
Example
public class Demo { public static void main(String[] args) { int val = 768; // integer System.out.println("Integer: "+val); // octal System.out.println("Octal String = " + Integer.toOctalString(val)); } }
Output
Integer: 768 Octal String = 1400
Advertisements