import java.util.*; class Foo { public void foo(Bar bar) { for (Iterator it = bar.getCns().iterator(); it.hasNext();) { final String o = (String) it.next(); } } } class Bar { private List cns; public List getCns() { if (cns == null) { return Collections.emptyList(); } return cns; } }