I read the output of the java 8 language specification type. It says that
List<String> ls = new ArrayList<>()
will be reduced first
ArrayList<α> -> List<String>
and then
α <= String
and in the end
α = String
It’s hard for me to understand how reducing the limit
ArrayList<α> -> List<String> to α <= String
. It would be very helpful if anyone could point to the logic using the java 8 language specification.
Below is a link to abbreviation
Thanks #Holger for the explanation. The following is my conclusion about the conclusion
new ArrayList<> -> List<String> to ArrayList<α> -> List<String>
Please correct me if I am wrong.
First, to find a temporary method for the constructor, we use # 15.9.3
Otherwise, the constructor arguments are arguments in the argument list of the class instance creation expression, if any, in the order they appear in the expression.
If the class instance creation expression uses <> for the class class elide arguments, the list of methods m1 ... mn is defined for purposes of overload resolution and type argument output.
Then # 18.5.2 is used to output
ArrayList<α> -> List<String>
Due to the fact that it is a political expression and does not have any parameters such as a wild card;
- Otherwise, the restriction formula is reduced and is included in B2.
source share