Finding pairs of numbers with a given difference
You don't need to use a map here. A set will work just as well, since you can recreate the original value by adding the difference again.

I'm not sure if it's possible to do it in one line (which of course is not necessarily the most readable solution), but you can get close by converting the input array into a set and then using streams:

static int[][] findPairsWithGivenDifference(final int[] values, final int difference) {

    Collection&lt;Integer&gt; valuesSet = Arrays.stream(values).boxed().collect(Collectors.toSet());

    return valuesSet.stream()
            .map(v -&gt; v - difference)
            .filter(valuesSet::contains)
            .map(v -&gt; new int[] { v, v + difference })
            .toArray(size -&gt; new int[size][2]);
}