⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collectingparameterdemo.java

📁 thinking in patterns
💻 JAVA
字号:
//: simplifying:CollectingParameterDemo.java
package simplifying;
import java.util.*;
import junit.framework.*;

class CollectingParameter extends ArrayList {}

class Filler {
  public void f(CollectingParameter cp) {
    cp.add("accumulating");
  }
  public void g(CollectingParameter cp) {
    cp.add("items");
  }
  public void h(CollectingParameter cp) {
    cp.add("as we go");
  }
}

public class CollectingParameterDemo extends TestCase {
  public void test() {
    Filler filler = new Filler();
    CollectingParameter cp = new CollectingParameter();
    filler.f(cp);
    filler.g(cp);
    filler.h(cp);
    String result = "" + cp;
    System.out.println(cp);
    assertEquals(result,"[accumulating, items, as we go]");
  }
  public static void main(String[] args) {
    junit.textui.TestRunner.run(
      CollectingParameterDemo.class);
  }
} ///:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -