Created
March 14, 2017 05:18
-
-
Save saqibmehmoodgit/9856e748f93f1839b505767281e21e96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem) { | |
int count = 0; | |
for (T e : anArray) | |
if (e.compareTo(elem) > 0) | |
++count; | |
return count; | |
} | |
////////// | |
Integer[] arr= new Integer[3]; | |
arr[0]=5; | |
arr[1]=7; | |
arr[2]=9; | |
Integer elem = 6; | |
System.out.println(" total is " + GenericMethods.countGreaterThan(arr, elem)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment