fork download
  1. class Ideone {
  2. private static int popcount(int i) {
  3. return Integer.bitCount(i);
  4. }
  5. public static void main(String[] args) {
  6. System.out.println(popcount('a'));
  7. System.out.println(popcount(127));
  8. System.out.println(popcount(255));
  9. System.out.println(Integer.MAX_VALUE);
  10. System.out.println(popcount(Integer.MAX_VALUE));
  11. }
  12. }
  13.  
Success #stdin #stdout 0.07s 52568KB
stdin
Standard input is empty
stdout
3
7
8
2147483647
31