Last active
May 10, 2021 18:36
-
-
Save 95Rajitha/c52b04c5431b6135fc16e66d318e5416 to your computer and use it in GitHub Desktop.
Type erasure when the type parameter is bounded
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 class Sample<E extends Comparable<E>> { | |
private E[] listOfItems; | |
public Sample(int size) { | |
this.listOfItems = (E[]) new Object[size]; | |
} | |
public void putItems(E data) { | |
// implementation | |
} | |
public E getItems() { | |
// implementation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment