class MaximumTest {
// determines the largest of three Comparable objects
public static <T extends Comparable<T>> int CountDuplicates(T[] anArray, T elem) {
int count = 0;
for (T e: anArray)
if (e.compareTo(elem) == 0)
++count;
return count;
}
public static void main(String args[]) {
double[] D_arr = {
1.2, 3.4, 0.0, 4.5, 0.0
};
int[] I_arr = {
0, 0, 0, 0, 1, 3, 5
};
System.out.println("No of zeros in Double Array = " + CountDuplicates(D_arr, 0.0));
System.out.println("No of zeros in Double Array = " + CountDuplicates(I_arr, 0));
}
}
What is the mistake in this code??