title: How to calculate sum of all numbers in a string
body: <p>How do I calculate the sum of all the numbers in a string?  In the example below, the expected result would be <code>4+8+9+6+3+5</code>.  My attempt is below.  Also could I calculate the sum of only those numbers which are divisible by 2?</p>
  
  <pre><code>int sum=0;
  String s = "jklmn489pjro635ops";
  for(int i=0; i&lt;s.length(); i++) {
      char temp = s.charAt(i);
      if (Character.isDigit(temp)) {
          int b = Integer.parseInt(String.valueOf(temp));
          sum=sum+b;
      }
  }
  System.out.println(sum);
  </code></pre>