Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
Advertisements
