title: java adding two int arrays with different lengths. why giving a result that is smaller than correct result?
body: <pre><code>public void add(int[]a1,int[]a2){       
  
      int atotal[] = new int[20];
      int capacity3 = Math.max(a1.length, a2.length);
  
      for (int i = 0; i &lt; capacity3; i++) 
      {
        int a3 = a1[i] + a2[i];
        if (a3 &gt; 9)
        {
          atotal[i] = a3 % 10;
          atotal[i+1] += a3 /10;
        }
        else
        {
          atotal[i] = a3;
        }
      } 
  
      for(int i = capacity3 - 1; i &gt;= 0; i--)
      {
        System.out.print(atotal[i] + " ");
      }
  }
  </code></pre>
  
  <p>In the addition of each elements in two arrays in my program, the carry of each single bit addition is not added to the next-insignificance bit .
  so if array1[0] = 9, array2[0] = 2.. my result[0] = 1 and my result[1] doesn't have the added one from [0].
  for example if i put 9999 and 1234 as the two arrays ,the result is 0123 instead of 11233.</p>