1. This is a generic Class<?> c = A.class ? It can be any type, such as ArrayList array = new ArrayList(); array.add(1); or array.add("1"); Yes, but the data type you put in this ArrayList is obviously messed up. Such data is unsafe and has no value, so it must be as follows ArrayList<String> array=new ArrayList<String>(); At this time, your array.add(1); An error will be reported and int type data cannot be stored. 2. Compilation does not report an error but a warning. Warn error is different. 3. After modifying the parameters as shown in the figure, there will be no warning.
1. This is a generic Class<?> c = A.class ? It can be any type, such as ArrayList array = new ArrayList(); array.add(1); or array.add("1"); Yes, but the data type you put in this ArrayList is obviously messed up. Such data is unsafe and has no value, so it must be as follows ArrayList<String> array=new ArrayList<String>(); At this time, your array.add(1); An error will be reported and int type data cannot be stored. 2. Compilation does not report an error but a warning. Warn error is different. 3. After modifying the parameters as shown in the figure, there will be no warning.
In fact, just write it like this.
Why pass
Integer[]
会有警告,因为参数类型是Object...
.