设计技巧33:从方法中获取信息 Collecting Parameter:集合参数,从方法中获取信息 容器比较常用

来源:互联网 发布:php网站开发视频教程 编辑:程序博客网 时间:2024/05/17 23:08
public class CollectParaT{
 
public void fill(CollectionParameter p){//收集器当参数传入方法
p.add("fill");//方法在收集器里面添加信息
}
 
public void fil(CollectionParameter p){
p.add("fil");
}
 
public static void testP(){
CollectParaT ct = new CollectParaT();
CollectionParameter cp = new CollectionParameter();
ct.fill(cp);
ct.fil(cp);
System.out.println(cp.size());//从收集器里面获取得到信息
}
原创粉丝点击