- 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 an integer into binary
To convert an integer to binary, use the Integer.toBinaryString() method in Java.
Let’s say the following is the integer we want to convert.
int val = 999;
Converting the above integer to binary.
Integer.toBinaryString(val)
Example
public class Demo { public static void main(String[] args) { int val = 999; // integer System.out.println("Integer: "+val); // binary System.out.println("Binary = " + Integer.toBinaryString(val)); } }
Output
Integer: 999 Binary = 1111100111
Advertisements