Limited wildcards in Java

This not normal

List<List<? extends Number>> a; List<List<Integer>> b; a = b; 

This is normal

  List<? extends Number> c; List<Integer> d; c = d; 

How to make it the first to compile?

+4
source share
2 answers

You can use this:

 List<? extends List<? extends Number>> a; List<List<Integer>> b; a = b; 
+11
source
 List<? extends List<? extends Number>> a = null; List<List<Integer>> b = null; a = b; 
+1
source

Source: https://habr.com/ru/post/1399797/


All Articles