I wrote:
this.array = (X[]) Array.newInstance(init.getClass(), size);
// ...
public List<X> get() {
return Collections.<X>unmodifiableList(this.array);
}
But I get the error:
unmodifiableList in Collections cannot be applied to (X[])
How can I create a generic unmodifiable list?
You can do this: