English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java's Integer.lowestOneBit() method

The Integer.lowestOneBit() method returns an int value with at most one bit in the position of the lowest bit ("rightmost") of the specified int value.

Here we have a decimal value294, and its binary is-

100100110

The lowest bit is calculated usinglowestOneBit()calculated in Java.

Example

public class Demo {
   public static void main(String[] args) {
      //binary100100110-
      int dec = 294;
      System.out.println("Count of one bits = " ); + Integer.bitCount(dec));
      System.out.println("Lowest one bit: " ); + Integer.lowestOneBit(dec));
   }
}

Output result

Count of one bits = 4
Lowest one bit: 2