java.lang.Long.bitCount()


java.lang.Long.bitCount()

package com.codingdict;



import java.lang.*;



public class LongDemo {



   public static void main(String[] args) {



      long l = 219;

      System.out.println("Number = " + l);



      /* returns the string representation of the unsigned long value 

         represented by the argument in binary (base 2) */

      System.out.println("Binary = " + Long.toBinaryString(l));



      // returns the number of one-bits 

      System.out.println("Number of one bits = " + Long.bitCount(l)); 

   }

}