winner4265975
public class Answer{
public static void main(String[] args){
Answer answer=new Answer();
Map<String,Object>[] data1=answer.toArray(2);
for(int i=0;i<data1.length;i++){
for(Map.Entry<String, Object> data:data1[i].entrySet())
System.out.println(data.getKey()+":"+data.getValue());
}
}
public Map<String,Object>[] toArray(int n){
Map<String,Object>[] array=new HashMap[n];
for(int i=0;i<n;i++){
array[i]=new HashMap<String,Object>();
array[i].put("name","漏洞"+i);
array[i].put("X",i*100);
array[i].put("Y",i*100);
}
return array;
}
}要注意一点就是不能创建泛型数组!而且一般用集合更好些,数组毕竟固定大小了!