KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > ForEachTest


1 package uk.co.jezuk.mango;
2
3 import junit.framework.*;
4
5 public class ForEachTest extends TestCase
6 {
7   java.util.List JavaDoc list;
8
9   public ForEachTest(String JavaDoc name) { super(name); }
10   public static Test suite() { return new TestSuite(ForEachTest.class); }
11
12   protected void setUp()
13   {
14     list = new java.util.ArrayList JavaDoc();
15     for(int i = 0; i < 10; ++i)
16       list.add(new Integer JavaDoc(i));
17   } // setUp
18

19   private class Print implements UnaryFunction
20   {
21     public Object JavaDoc fn(Object JavaDoc o)
22     {
23       System.out.println(o.toString());
24       return null;
25     }
26   } // Print
27

28   public void test1()
29   {
30     Algorithms.forEach(list, new Print());
31   } //
32
} // ForEachTest
33
Popular Tags