Creating Generics Instances: New ArrayList <?> () Vs new ArrayList <List <? >> ()
3 answers
When you create an ArrayList, you need to determine the type of objects it will contain:
- in the first example, you create an ArrayList that will contain lists of unknown generic types, but they will all be lists.
- in the second example, you are trying to create an ArrayList of an unknown type that is not allowed.
+3