Find given number by summing up integers from 2 sorted arrays
Your code reads easily: it loops over the two arrays to find the corresponding pairs.

However, it doesn't take advantage of the fact that both arrays are sorted. You can refer to this Stack Overflow answer by Mark Byers to see how it is possible to do it in linear time and constant storage when both arrays are sorted. Quoting for reference:


  
  Start with two pointers, one pointing at the smallest element of A, the other pointing to the largest element of B.
  Calculate the sum of the pointed to elements.
  If it is smaller than k increment the pointer into A so that it points to the next largest element.
  If it is larger than k decrement the pointer into B so that it points to the next smallest element.
  If it is exactly k you've found a pair. Move one of the pointers and keep going to find the next pair.
  


In this version, each pointer will always go forward (for the first array) or backward (for the second array), so there will be at most A.length + B.length moves.

Putting this into code, you would have:

private static void findPairs(int[] array1, int[] array2, int sum) {
    int l = 0, r = array2.length - 1;
    while (l &lt; array1.length &amp;&amp; r &gt;= 0) {
        int s = array1[l] + array2[r];
        if (s &lt; sum) {
            l++;
        } else if (s &gt; sum) {
            r--;
        } else {
            System.out.println("Pair found at index : " + l + " " + r);
            l++;
        }
    }
}