首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

代码复用的守则

2012-12-23 
代码复用的规则两个方法都对List对象pool做了操作,但是,实际上,我们可能只是想对List接口的不同实现Vector

代码复用的规则

两个方法都对List对象pool做了操作,但是,实际上,我们可能只是想对List接口的不同实现Vector、ArrayList等做存取测试。所以,代码应该这样写:?
public class Test{
private List pool = new Vector();
public void testAdd(List pool, String str){
pool.add(str);
}
public Object testGet(List pool, int index){
pool.get(index);
}
}

热点排行