The method takes an array of integers and returns true if there exists any item in the array that satisfies a specified condition. For instance, the following code fragment:
int[] input = {100, 37, 49};
boolean result1 = contains(input, new Prime( ));
boolean result2 = contains(input, new PerfectSquare( ));
boolean result2 = contains(input, new Negative( ));
result1 would return true since 37 is prime, result2 would also return true since 100 and 49 are perfect squares, and result3 would return false because none of the elements are negative. The code needs to implement:
an interface used to specify the second parameter to contains.
the contains method itself (which is a static method).
the classes Negative, Prime, and Perfect Square.
After doing this we have to rewrite it using generics. I can write the classes no problem but I'm struggling with getting them to work together. I think I'm messing up with generics. My error message comes up in my main method where I wrote:
boolean result1 = contains(, new Prime
Obviously, this isn't right.