拿什么来拯救你---我的多条记录?---小插曲!!!
请问我刚刚发现的一个小问题:
Iterator 与 Collection 都是在java.util包中定义的 Interface(接口类),而在Java中Interface(接口类)是不能被实例化的,即 Iterator 不能写成 Iterator iterator,Collection 也不能写成Collection collect,但是为什么在如下程序中可以这样写???
.........
Collection collect=new TestGmccClient1().getCollectionClient(str);//***
Iterator iterator=collect.iterator();//***
String columnName[]={"ID","Name","Sex","Nationality"};
String rowData[][] = new String[collect.size()][columnName.length];
int i=0;
while(iterator.hasNext()){
EmployeeBEO empBEO = (EmployeeBEO) iterator.next();
rowDate[i][0] = new String(Integer.toString(i+1));
rowDate[i][1] = empBEO.getName();
rowDate[i][2] = empBEO.getSex();
rowDate[i][3] = empBEO.getNationality();
i++;
}
------小插曲------