| Page 12 of 38 Prev | Index | Next |
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
public class ExLists {
public static void f(Object o) {
System.out.println(o);
}
public static void main(String[] args) {
List t = new ArrayList();
t.add(new Integer(1));
t.add(new Integer(2));
t.add(new Integer(3));
// loop the list
for(Iterator i=t.iterator();i.hasNext();) {
Object o = i.next();
ExLists.f(o);
}
}
}
def f(x):
print x
[f(x) for x in T]
| Page 12 of 38 Prev | Index | Next |