62,616
社区成员
发帖
与我相关
我的任务
分享
private AccountPO account = new AccountPO();
private List<NodePO> nodeList = new ArrayList<NodePO>();
private LogonBiz logonBiz ;
public String userLogon(){
if(logonBiz.userLogon(account , nodeList)){
System.out.println(account.getName());
System.out.println(nodeList.size());
return "success";
}else
return "error";
}
public interface LogonBiz {
public boolean userLogon(AccountPO account , List<NodePO> nodeList);
}
private LogonDao logonDao ;
private NodeDao nodeDao ;
public boolean userLogon(AccountPO account , List<NodePO> nodeList ) {
try{
if(logonDao.logSuccess(account , nodeList)){
(1) nodeList = nodeDao.getAccount_NodeList(account);
(2) nodeList.addAll(nodeDao.getAccount_NodeList(account));
System.out.println(nodeList.size()); //这一块 nodelist 值是正确的
return true;
}else
return false;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public class ValueTest {
public static void main(String[] args){
value myV = new value();
System.out.println("================");
myV.setName("456");
System.out.println(myV.getName());
System.out.println("================");
VDao dao = new IvDao();
dao.createV(myV);
System.out.println("================");
System.out.println(myV.getName());
System.out.println("================");
}
}
class value {
private String name = null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
interface VDao {
public void createV(value v);
}
class IvDao implements VDao {
[code=Java]public void createV(value v) {
value vt = new value();
vt.setName("123");
v = vt;
System.out.println(v.getName());
}
public void createV(value v) {
value vt = new value();
vt.setName("123");
v = vt;
System.out.println(v.getName());
}
这段代码 之后 myV 的值在最后并没有被改变,而这里我使用的是 v = vt ; 其中的
nodeList.addAll(nodeDao.getAccount_NodeList(account));