@Test public void numberOfBitsInOneIsOne() { assertEquals(1, bitsCounter.countBitsToOneBasedOnString(1)); }
public int countBitsToOneBasedOnString(int n) { int result = 0; String binaryNumber = Integer.toBinaryString(n); for (char c : binaryNumber.toCharArray()) { result += c == '1' ? 1 : 0; } return result; }
BitsCounter { public int countBitsToOneBasedOnString(int n) { int result = 0; String binaryNumber = Integer.toBinaryString(n); for (char c : binaryNumber.toCharArray()) { result += c == '1' ? 1 : 0; } return result; } }
BitsCounter { public int countBitsToOneBasedOnString(int n) { int result = 0; String binaryNumber = Integer.toBinaryString(n); for (char c : binaryNumber.toCharArray()) { result += c == '1' ? 1 : 0; } return result; }  }
BitsCounter { public int countBitsToOneBasedOnString(int n) { int result = 0; String binaryNumber = Integer.toBinaryString(n); for (char c : binaryNumber.toCharArray()) { result += c == '1' ? 1 : 0; } return result; }  int countBitsToOneBasedOnString(int n); int countBitsToOneBasedOnBinaryOperators(int n); }
BitsCounter { public int countBitsToOneBasedOnString(int n) { int result = 0; String binaryNumber = Integer.toBinaryString(n); for (char c : binaryNumber.toCharArray()) { result += c == '1' ? 1 : 0; } return result; }  int countBitsToOneBasedOnString(int n); int countBitsToOneBasedOnBinaryOperators(int n);  }