我有一個用戶配置文件類,只是想知道加載它的最佳方式是。我有下面的代碼,並想知道它是否是正確的方式來做到這一點。從數據庫檢索配置文件 - Java
UserProfile userProfile = null;
char[] password = {'a','b','c'};
for(UserProfile profile : UserProfiles){
if(compareUserNameAndPassword("userName", password)){
userProfile = profile;
}
}
而且我的個人資料類:
package jlibfprint;
public class UserProfile extends Profile {
/**
* constructor
*/
public UserProfile(String userName, int id, char[] password){
this.name = userName;
this.id = id;
this.password = password;
}
/**
* Users password
*/
private char[] password;
/**
* Set User password
* @param password
*/
public void setPassword(char[] password){
this.password = password;
}
/**
* compare passwords
*/
public boolean compareUserNameAndPassword(String userName,char[] password) {
if(this.name.equals(userName) && this.password.equals(password)){
return true;
}
return false;
}
}
你的負載是什麼意思? – unholysampler
你的意思是最好的? –
你的代碼甚至不會編譯。 – 2012-12-19 20:48:35