

- 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
Java Program to display Bit manipulation in Integer
Let’s say we have the following decimal number, which is binary 100100110.
int dec = 294;
To perform bit manipulation, let us count the number of 1 bits in it. We have used bitCount() method for this purpose.
Integer.bitCount(dec);
The following is an example to display bit manipulation in given Integer.
Example
public class Demo { public static void main(String []args) { // binary 100100110 int dec = 294; System.out.println("Count of one bits = " + Integer.bitCount(dec)); } }
Output
Count of one bits = 4
- Related Questions & Answers
- Bit manipulation program in 8051
- Java Program to Print an Integer
- ConvertDecimal to equivalent 32-bit unsigned integer in C#
- Program to convert set of Integer to Array of Integer in Java
- Java Program to convert integer to boolean
- Java Program to convert integer to octal
- Java Program to convert integer to hexadecimal
- Java Program to convert boolean to integer
- Java Program to decode string to integer
- Display the maximum of three integer values in Java
- Display the minimum of three integer values in Java
- Java Program to flip a bit in a BigInteger
- Java Program to check for Integer overflow
- Convert Decimal to equivalent 8-bit unsigned integer in C#
- Java Program to convert from integer to String
Advertisements