import java.math.BigInteger;

/**
 * 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
 *
 * What is the sum of the digits of the number 2^1000?
 *
 * @author David Clutter
 */
public class Problem0016 {

    public static void main(final String[] args) {
        final String numberString = BigInteger.valueOf(2).pow(1000).toString();
        long sum = 0;
        for(final char digit : numberString.toCharArray()) {
            sum += Character.getNumericValue(digit);
        }
        System.out.println(sum);
    }
}
@@ -357,102 +357,49 @@
     
-long sum = 0;%0A        for(final char digit : numberString.toCharArray()) %7B%0A            sum += 
+final int sum = numberString.chars().map(
 Char
@@ -403,17 +403,18 @@
 haracter
-.
+::
 getNumer
@@ -424,26 +424,16 @@
 alue
-(digit);%0A        %7D
+).sum();
 %0A   

modify problem 0016 to use java 8 stream