Skip to content

Instantly share code, notes, and snippets.

@95Rajitha
Last active May 10, 2021 18:36
Show Gist options
  • Save 95Rajitha/c52b04c5431b6135fc16e66d318e5416 to your computer and use it in GitHub Desktop.
Save 95Rajitha/c52b04c5431b6135fc16e66d318e5416 to your computer and use it in GitHub Desktop.
Type erasure when the type parameter is bounded
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