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;
  }
This implementation is based on Strings. Transforming an integer into the binary
representation we can obtain an String and use it to count the number of elements equals to
'1'. This implementation is slow because it's based on transform the parameter into the binary
representation which complexity order is O(N) where N is the number of digits in the parameter
binary representation.

In addition we have to count the number of elements inside the String obtained and the
complexity order of that operation is again O(N).

In space terms, the complexity order is O(N) where N is the number of digits used to represent
the parameter using binary format. This cost is associated to the usage of an auxiliary String
to keep the binary result.

To get the binary representation we are going to use a static method of Integer class:
Integer.toBinaryString.
src/main/java/com/github/pedrovgs/problem1/BitsCounter.java