@@ -0,0 +1,1061 @@
+import java.util.HashSet;%0A%0Apublic class ArrayProblems %7B%0A%0A%09/*%0A%09 * Prints out the elements of an array that have the specified difference.%0A%09 * %0A%09 * @param arr an array containing integers to check for the difference%0A%09 * @param diff the value of the difference to check for among array elements%0A%09 * %0A%09 */%0A%09public static void findDiffExists (int %5B%5D arr, int diff) %7B%0A%09%0A%09%09if (arr == null) throw new IllegalArgumentException ();%0A%09%09%0A%09%09System.out.println (%22Diff = %22 + diff);%0A%09%09%0A%09%09int len = arr.length;%0A%09%09HashSet%3CInteger%3E hs = new HashSet%3CInteger%3E (); %0A%09%09%0A%09%09for (int i = 0; i %3C len; i ++) %7B%0A%09%09%09hs.add(arr%5Bi%5D);%0A%09%09%7D%0A%09%09%0A%09%09for (int i = 0; i %3C len; i++) %7B%0A%09%09%09if (hs.contains(arr%5Bi%5D - diff)) %7B%0A%09%09%09%09System.out.println (arr%5Bi%5D + %22, %22 + (arr%5Bi%5D - diff));%0A%09%09%09%7D%0A%09%09%7D%0A%09%09System.out.println();%0A%09%7D%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09// TODO Auto-generated method stub%0A%09%09int %5B%5D arr = %7B10, 20, 30, 40, 15%7D;%0A%09%09ArrayProblems.findDiffExists(arr, 10);%0A%09%09ArrayProblems.findDiffExists(arr, -10);%0A%09%09ArrayProblems.findDiffExists(arr, 0);%0A%09%09ArrayProblems.findDiffExists(arr, -1);%0A%0A%09%7D%0A%0A%7D%0A

Create ArrayProblems.java