1mport java.io.Serializable;
2import java.util.ArrayList;
3import java.util.List;
4
5
6public class test3 implements Serializable {
7 public static void main(String[] args) {
8 ArrayList<String> x1 = new ArrayList<String>();
9 foo(x1); 错误
10
11 ArrayList<Object> x2 = new ArrayList<String>();错误
12 foo(x2);
13
14 ArrayList<Object> x3 = new ArrayList<Object>();
15 foo(x3);
16
17 ArrayList x4 = new ArrayList();
18 foo(x4);
19 }
20 public static void foo(List<Object> list){
21
22 }
23}
24
2import java.util.ArrayList;
3import java.util.List;
4
5
6public class test3 implements Serializable {
7 public static void main(String[] args) {
8 ArrayList<String> x1 = new ArrayList<String>();
9 foo(x1); 错误
10
11 ArrayList<Object> x2 = new ArrayList<String>();错误
12 foo(x2);
13
14 ArrayList<Object> x3 = new ArrayList<Object>();
15 foo(x3);
16
17 ArrayList x4 = new ArrayList();
18 foo(x4);
19 }
20 public static void foo(List<Object> list){
21
22 }
23}
24