不明白???

wwx 05-05-10

我是学JAVA的新手,看到一个网页不太明白,请高手指教12:
(1)public Iterator getUsers() {
final ResultSet rs = userDbQuery();
return new Iterator() {
private Object next;

public void hasNext() {
if (next == null) {
if (! rs.next()) {
return false;
}
next = rs.getString(1);
}
return true;
}

public Object next() {
if (! hasNext()) {
throw new NoSuchElementException();
}
String retval = next;
next = null;
return retval;
}

public void remove() {
throw new UnsupportedOperationException("no remove allowed");
}
}
}
(2)public Iterator getUsers() {
ResultSet rs = userDbQuery();
List list = new ArrayList()
while (rs.next()) {
list.add(rs.getString(1));
}
return list.iterator();
}
(3)为何1返回的是指针而2不是