函数定义泛型List<Map<String, ?>> map,编译无法通过,写成List<? extends Map<String, ?>> map即可
package seaboot.test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Test2 {
    public static void test(List<Map<String, ?>> map) {

    }

    public static void main(String[] args) throws IOException {
        List<Map<String, Object>> map = new ArrayList<>();
        test(map);
    }
}


package seaboot.test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Test2 {
    public static void test(List<? extends Map<String, ?>> map) {

    }

    public static void main(String[] args) throws IOException {
        List<Map<String, Object>> map = new ArrayList<>();
        test(map);
    }
}

 

相关文章:

  • 2021-10-30
  • 2021-09-11
  • 2022-02-16
  • 2021-08-23
  • 2022-12-23
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2022-01-12
  • 2021-08-06
  • 2021-07-15
  • 2022-12-23
  • 2022-01-11
  • 2021-07-19
相关资源
相似解决方案