求JAVA代码

2025-01-02 23:05:08
推荐回答(2个)
回答1:

package code;

public class User {
private String ID;
private String username;
private String userpasssword;
public String getID() {
return ID;
}
public void setID(String id) {
ID = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpasssword() {
return userpasssword;
}
public void setUserpasssword(String userpasssword) {
this.userpasssword = userpasssword;
}

}

////////////////////////////////////////////
package code;

import java.util.ArrayList;
import java.util.List;

public class Test {
List list=new ArrayList();
public void setUser(String ID,String username,String userpasssword){

User user=new User();
user.setID(ID);
user.setUsername(username);
user.setUserpasssword(userpasssword);
list.add(user);
}
public boolean YanZheng(String ID){
User u=null;
for(int i=0;i u=(User)list.get(i);
if(u.getID().equals(ID)){
return true;
}

}

return false;

}
public static void main(String args[]){
Test t=new Test();
t.setUser("001", "李雷", "123");
System.out.println(t.YanZheng("001"));
}
}
/////////////////////////////
/////网页就自己写吧 主要的bean就是这样

回答2:

做个遍历,找到了就跳出循环。并且把当前对象得到,显示到页面。