Tableau générique Java
public <T> T[] getArray(int size) {
T[] genericArray = (T[]) new Object[size];
return genericArray;
}
Mosel Grepper
public <T> T[] getArray(int size) {
T[] genericArray = (T[]) new Object[size];
return genericArray;
}
public class GenSet<E> {
private E[] a;
public GenSet(Class<E> c, int s) {
// Use Array native method to create array
// of a type only known at run time
@SuppressWarnings("unchecked")
final E[] a = (E[]) Array.newInstance(c, s);
this.a = a;
}
E get(int i) {
return a[i];
}
}