Thursday, April 26, 2012

Iterable interface

Learnt a new thing in Java today:

Given a class:

public class DocumentPreprocessor implements Iterable> {
    ...
   public Iterator> iterator()
}



You can use it like this:

for (List sentence : new DocumentPreprocessor(filename)) { ... }

Which I didn't know. So there you go. Learn a new thing everyday :)