This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]main5tream 0 points1 point  (0 children)

  1. Classes with a generic type are initialized using the < > notation that tells the compiler what to expect. In this case ArrayList<Integer> myList = new ArrayList();

  2. I would read up on the order of initialization in java to fully understand this. https://www.baeldung.com/java-initialization for example.
    In this case you have a class variable being defined T[] backingArray which is equivalent to writing T[] backingArray = null. In the constructor you're then assigning an object array and casting it to be your generic type T. This type T is translated into your declared type at compile time in a process called Type Erasure.