Find all pairs in an array that sum to a given number without using HashMap Find all pairs in an array that sum to a given number without using HashMap.
  Duplicate pairs are not allowed. Input array cannot be modified.
  
  input:   {-2, -1, -1, 5, 7, 7, 7, 7, 8}, target = 7
  
  output: (-1, 8)


As it is mentioned, using HashMap is not allowed, so I decided to use binary search.

GitHub

public class TwoSumProblemUsingBinarySearch {

    public static class Pair {

        private final int x;
        private final int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }

        @Override
        public boolean equals(Object other) {
            if (other instanceof Pair) {
                Pair o = (Pair) other;
                return this.x == o.x &amp;&amp; this.y == o.y;
            }

            return false;
        }

        @Override
        public String toString() {
            return String.format("(%d, %d)", x, y);
        }
    }

    public static Set&lt;Pair&gt; findAllParis(int input[], int target) {
        int numbers[] = Arrays.copyOf(input, input.length);
        Set&lt;Pair&gt; pairs = new HashSet&lt;&gt;();

        Arrays.sort(numbers);

        for (int low = 0, high = input.length - 1; low &lt; high; ) {
            int sum = input[low] + input[high];

            if (sum &gt; target) {
                high--;
            } else if (sum &lt; target) {
                low++;
            } else {
                pairs.add(new Pair(input[low], input[high]));
                high--;
                low++;
            }
        }

        return pairs;
    }
}

@Test
public void findAllParis() throws Exception {

    System.out.println(TwoSumProblemUsingBinarySearch.findAllParis(new int[]{-2, -1, -1, 5, 7, 7, 7, 7, 8}, 7));
    assertEquals(1, TwoSumProblemUsingBinarySearch.findAllParis(new int[]{-2, -1, -1, 5, 7, 7, 7, 7, 8}, 7).size());
}
Typo in method name as pointed out by @Stingy. Should be findAllPairs.
Accessing wrong array: You are reading values from input instead of your sorted copy numbers. This is probably a typo. E.g. int sum = input[low] + input[high]; should be int sum = numbers[low] + numbers[high];
Your for loop has an empty update statement, this isn't wrong per-se but a bit unusual. Consider an alternative using while instead:

int low = 0, high = numbers.length-1;
while (low &lt; high) {
    int sum = numbers[low] + numbers[high];
    //...
}

Insufficient test: As evidenced by its failure to catch the bug in 2. the test is too limited to be of much help. Consider checking more than one example (especially corner-cases like an empty input array) and checking against the expected output instead of just its size.