jsp arrayList中remove方法應用

來源:互聯網
上載者:User

網頁特效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;
    }

}

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.