Sorry if this is stupid question but i have the following method...
static <V> V[] getRange(V[] arr, V val, int range) {
ArrayList<V> inRange = new ArrayList<>();
int index = -1;
for (int i = 0; i < arr.length; i++)
if (arr[i] == val)
index = i;
for (int i = 0; i < arr.length; i++)
if (Math.abs(i - index) <= range)
inRange.add(arr[i]);
return (V[]) inRange.toArray();
}
With this method you're supposed to be able to supply an element and a range, and return an array with nearby values. For example in psuedocode this what should happen.
getRange({1,2,3,4,5,6}, 5, 2) = {3,4,5,6}
However if i try to use this method with an int i get the following message:
The method getRange(V[], V, int) in the type myType is not applicable for the arguments (int[], int, int)