網頁特效phttp://www.111cn.net/網頁特效p.html target=_blank >jsp教程 arraylist中remove方法應用
import java.util.arraylist;
import java.util.list;
import test.common.user;
public class test2 {
private static final long serialversionuid = 1l;
public static void main(string[] args){
list<user> list = new arraylist<user>();
user u1 = new user();
u1.setname("a");
user u2 = new user();
u2.setname("b");
user u3 = new user();
u3.setname("c");
list.add(u1);
list.add(u2);
list.add(u3);
for(int i = 0;i<list.size();i++){
system.out.println("1:"+list.get(i).getname());
}
system.out.println("2:"+u2.getname());
list.remove(u2);
for(int i = 0;i<list.size();i++){
system.out.println("3:"+list.get(i).getname());
}
}
}
package test.common;
import java.io.serializable;
public class user implements serializable {
private static final long serialversionuid = 1l;
private string name;
private string pwd;
private string img;
private int pointx;
private int pointy;
private string message;
public string getname() {
return name;
}
public void setname(string name) {
this.name = name;
}
public string getpwd() {
return pwd;
}
public void setpwd(string pwd) {
this.pwd = pwd;
}
public string getimg() {
return img;
}
public void setimg(string img) {
this.img = img;
}
public int getpointx() {
return pointx;
}
public void setpointx(int pointx) {
this.pointx = pointx;
}
public int getpointy() {
return pointy;
}
public void setpointy(int pointy) {
this.pointy = pointy;
}
public string getmessage() {
return message;
}
public void setmessage(string message) {
this.message = message;
}
public boolean equals(object obj) {
if(obj==null)
return false;
if(obj!=this)
return false;
if(getclass() != obj.getclass())
return false;
return true;
}
}