MyException - 我的异常网
当前位置:我的异常网» J2SE » 为什么小弟我的removeAll不好使

为什么小弟我的removeAll不好使

www.MyException.Cn  网友分享于:2013-12-29  浏览:27次
为什么我的removeAll不好使?
List<UserApp> synlist;
List<UserApp> userapplist;
上面两集合一样,synlist中数据有包含userapplist,我打印出来了,可以看到了,但是我用
synlist.removeAll(userapplist)语句,还是移除不掉里面的数据
我的重写equals方法,但是不管用,大家帮我看一下我重写的代码(我是根据eclipse自动生成的)



package com.vlinko.client.android.model;

import android.graphics.drawable.Drawable;

public class UserApp {
public String id;
public String appName = "";
public String packageName = "";
public String versionName = "";
public String versionCode = "";
public Drawable appIcon = null;

public UserApp() {
super();
// TODO Auto-generated constructor stub
}
public UserApp(String id, String appName, String packageName,
String versionName, String versionCode, Drawable appIcon) {
super();
this.id = id;
this.appName = appName;
this.packageName = packageName;
this.versionName = versionName;
this.versionCode = versionCode;
this.appIcon = appIcon;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getVersionName() {
return versionName;
}
public void setVersionName(String versionName) {
this.versionName = versionName;
}
public String getVersionCode() {
return versionCode;
}
public void setVersionCode(String versionCode) {
this.versionCode = versionCode;
}
public Drawable getAppIcon() {
return appIcon;
}
public void setAppIcon(Drawable appIcon) {
this.appIcon = appIcon;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((appIcon == null) ? 0 : appIcon.hashCode());
result = prime * result + ((appName == null) ? 0 : appName.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((packageName == null) ? 0 : packageName.hashCode());
result = prime * result
+ ((versionCode == null) ? 0 : versionCode.hashCode());
result = prime * result
+ ((versionName == null) ? 0 : versionName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
UserApp other = (UserApp) obj;
if (appIcon == null) {
if (other.appIcon != null)
return false;
} else if (!appIcon.equals(other.appIcon))
return false;
if (appName == null) {
if (other.appName != null)
return false;
} else if (!appName.equals(other.appName))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (packageName == null) {
if (other.packageName != null)
return false;
} else if (!packageName.equals(other.packageName))
return false;
if (versionCode == null) {
if (other.versionCode != null)
return false;
} else if (!versionCode.equals(other.versionCode))
return false;
if (versionName == null) {
if (other.versionName != null)
return false;
} else if (!versionName.equals(other.versionName))
return false;
return true;
}
@Override
public String toString() {
return "UserApp [appIcon=" + appIcon + ", appName=" + appName + ", id="

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有