Type inference from unknown type

In Java, it is not possible to instantiate an unknown type:

List<?> list1 = new ArrayList<?>() 

gives the following error:

 required: class or interface without bounds found: ? 1 error 

But do

 List<?> list2 = new ArrayList<>(); 

compile without errors.

My question is this: what is the type that you selected, and what is its logic?

+4
source share

All Articles