条款我有一类球员,我从数据库加载:凡在Java中
public class Player{
int id, score;
String name;
public Player(int id, String name, int score) {
this.id = id;
this.name = name;
this.score = score
}
public int getID() {
return id;
}
public String getName() {
return name;
}
public String getScore() {
return score;
}
}
类主要有所有的人都在ArrayList<Player> player
。
是否有可能通过类似于SQL中的where
子句找到该类的特定实例? 我只需要名称,如果我有身份证。
例子:
"SELECT name FROM Player WHERE id = 5";
你现在如何查询数据库?如果你改变查询比遍历所有结果更好。 – 2012-03-11 18:14:51