Created
May 11, 2021 09:49
-
-
Save 95Rajitha/add5ade335087059427c977a2a658563 to your computer and use it in GitHub Desktop.
bounded type erasure for method level erasure
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
//method declartation to elaborate bounded method type parameter | |
public static <E extends Comparable<E>> void countElements(E[] array) { | |
private int count =0; | |
for (E element : array) { | |
count++; | |
} | |
System.out.println(count); | |
} | |
//Replacing E with Comparable | |
public static void countElements(Comparable[] array) { | |
private int count =0; | |
for (Comparable element : array) { | |
count++; | |
} | |
System.out.println(count); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment