java bean的引用,注意java的对象引用

要注意,当前拿到的“对象引用”, 是不是 指向 最新的实例, 没有的话, 要重新 生成实例去指向。

代码例子:

69c5a8ac3fa60e0848d784a6dd461da6.pngAnsweringRuleInfo bhRule = accountGenerator.getAnswerRule(mailboxId, false, AnsweringRuleType.BusinessHours);for(int j=0; j

bhRule.getPhones().get(j).setEnabled(false);

bhRule.setPhones(Arrays.asList(bhRule.getPhones().get(j)));

}

accountGenerator.setAnswerRule(mailboxId, bhRule);

69c5a8ac3fa60e0848d784a6dd461da6.png

解析:

bhRule.getPhones().get(j).setEnabled(false);

操作后, 若不对bRule重新设置

:bhRule.setPhones(Arrays.asList(bhRule.getPhones().get(j)));

(bhRule.getPhones(). 返回List)

accountGenerator.setAnswerRule(mailboxId,

bhRule) 后, 该account 下ForwardPhoneInfos  各个ForwardPhoneInfo

保持原来的status,映射不到。

69c5a8ac3fa60e0848d784a6dd461da6.pngRingGroup ringGroup4;

ss.getUserCallHandlingComponent().save();

openCallForwarding(hours);

ringGroup4=ss.getUserCallHandlingComponent().getRingGroupByLabel(hours, firstDeskPhoneLabel);

ArrayList phoneLabels =ringGroup4.getPhoneLabelsInGroup();

assertEquals(phoneLabels.get(0), firstDeskPhoneLabel, "The ring group include " +firstDeskPhoneLabel);

assertEquals(phoneLabels.get(1), forwardPhoneNames[1], "The ring group include " + forwardPhoneNames[1]);

assertEquals(phoneLabels.size(),2, "The ring group size is 2");

assertFalse(ringGroup4.isMoveUpButtonEnabled(),"The ringGroup move up button is disable.");

assertTrue(ringGroup4.isMoveDownButtonEnabled(),"The ringGroup move down button is enable.");

logBusiness("1.2 Move the group at the middle of list using ‘\\/‘ arrow > Save > Check arrows for this group at the \"Call Handling & Forwarding\"");

ringGroup4.moveGroupDown();

ringGroup4=ss.getUserCallHandlingComponent().getRingGroupByLabel(hours, firstDeskPhoneLabel);

ss.getUserCallHandlingComponent().save();

openCallForwarding(hours);

assertTrue(ringGroup4.isMoveUpButtonEnabled(),"The ringGroup move up button is enable.");

assertTrue(ringGroup4.isMoveDownButtonEnabled(),"The ringGroup move down button is enable.");

69c5a8ac3fa60e0848d784a6dd461da6.png

解析:

对象引用 ringGroup4

ringGroup4 =ss.getUserCallHandlingComponent().getRingGroupByLabel(hours,

firstDeskPhoneLabel);

获取到第一个位置的ringGroup,

若 ringGroup4.moveGroupDown();

此时RingGroup自身类成员发生改变,

ss.getUserCallHandlingComponent().getRingGroupByLabel(hours,

firstDeskPhoneLabel);获取到的实例也被改变, 而ringGroup4 还是指向原来的对象

所以此时ringGroup4需要重新指向。

student stu1 = new student();

通常把这条语句的动作称之为创建一个对象,其实,它包含了四个动作。

1) 右边的"new student" ,是以student 类为模板,在堆空间里创建一个student 类的对象(

也简称为student 对象) 。

2) 末尾的() 意味着,在对象创建后,立即调用student 类的构造函数,对刚生成的对象进行初始化。

构造函数是肯定有的。如果你没写,Java 会给你补上一个默认的构造函数。

3) 左边的"student stu1" 创建了一个student 类引用变量。所谓student

类引用,就是以后可以用来指向某个

4)"=" 操作符使对象引用指向刚创建的那个student 对象。

原文:http://www.cnblogs.com/jenniferhuang/p/3760841.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值