Web effects phttp://www.111cn.net/Web effects p.html target=_blank >jsp Tutorials The application of Remove method in ArrayList
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;
}
}