mixamus13
12/20/2019 - 8:27 PM

Integer.bitCount

package com.tutorialspoint;

import java.lang.*;

public class IntegerDemo {

   public static void main(String[] args) {

      int i = 177;
      System.out.println("Number = " + i);
    
      /* returns the string representation of the unsigned integer value 
         represented by the argument in binary (base 2) */
      System.out.println("Binary = " + Integer.toBinaryString(i));

      // returns the number of one-bits 
      System.out.println("Number of one bits = " + Integer.bitCount(i)); 
   }
}