ArrayList depart_list=new ArrayList();
解决方案 »
- eclipse下编辑jsp无提示功能的问题
- 如CSDN一样;每天登陆不管多少次;给加一次分
- 帮忙看个错误
- tomcat配置
- 为什么支持jsp的虚拟主机那么少,而asp,php到处都是?
- select菜单的动态初始值生成???
- tomcat 跟IIS结合?马上给分
- 我在安装jive3.13第二步就出现了乱码,那位大哥给解决一下.
- 微软的JDBC驱动程序不支持absolute方法,怎么实现分页
- 请问在TOMCAT4.1.18服务器+JDK1.4上怎么安装JDBC2.0?
- 页面text传参的问题,急,谢谢。。。。。。。。。。。。。。。。。。。。
- CLI0125E Function sequence error,这样的错,谁遇见过。
这一句每一次都创建新的对象所以 if(!depart_list.contains(departbean))
depart_list里面的对象的内存地址都是不一样的,尽管他们的值可能重复
明白吗?你只能遍历整个ArrayList,然后用equals比较
1:boolean a = true;
Iterator it = depart_list.iterator();
while (it.hasNext())
{
String s = it.next().toString();
String subs = s.substring(0, 2);
String newbmbh=(String)departbean.getBmbh();
if (newbmbh.equals(subs))
{
a=false;
}
}
if(a)
{
depart_list.add(departbean);
}
-----------------------------
String s = it.next().toString();
这句好象取不出东西,是怎么回事?
String s=(String)arraylist.get(i);