sum digits a number in Java
<p>I have a bunch of numbers.Each digit of those numbers is concatenated n times and then summed. I have to write function which is returns 1 if sum equals number else returns 0.</p>

<pre><code>public static int checkConcatenatedSum(int n, int catlen) {
        char[] charArray = String.valueOf(n).toCharArray();
        int[] test = new int[charArray.length];
        String[] digit = new String[charArray.length];
        int sum = 0;
        for (int j = 0; j &lt; charArray.length; j++){
            for(int i = 0; i &lt; catlen; i++){
                digit[j] += charArray[j];
            }
            test[j] = Integer.parseInt(digit[j]);
            sum += test[j];
        }
        if(sum == n){
            return 1;
        }
        else return 1;
    }
</code></pre>

<p><code>digit[j]</code> begins with <em>null</em> every time.</p>
