In Java, I need to return an Iterator from my method. My data comes from another object which usually can give me an iterator so I can just return that, but in some circums
Sorry, I figured it out. You need to use an assignment so that the compiler can figure out the parameterized type.
public Iterator iterator() {
if (underlyingData != null) {
return underlyingData.iterator();
} else {
List empty = Collections.emptyList(); // param type inference
return empty.iterator();
}
}