
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Integer LowestOneBit Method in Java
The method Integer.lowestOneBit() returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value.
Here we have a decimal value 294, whose binary is −
100100110
The lowest one bit is calculated using the lowestOneBit() method in Java.
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)); System.out.println("Lowest one bit: " + Integer.lowestOneBit(dec)); } }
Output
Count of one bits = 4 Lowest one bit: 2
Advertisements