What happens inside Java\'s ArrayList (and probably many other classes) is that there is an internal Object[] array = new Object[n];, to w
ArrayList
Object[] array = new Object[n];
Array is object too. Here T[] array = (T[]) new Object[n] you cast only (T[]) object type not elements in the array.
T[] array = (T[]) new Object[n]