课程: Java Memory Management: Values and References
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Avoiding escaping references - Java教程
课程: Java Memory Management: Values and References
Avoiding escaping references
- [Instructor] So how to fix these escaping references? Well, in order to start, we'll need to make user cloneable, so we say influence clonenable and then, below, we are actually overriding the clone function. And actually you always have to override the clone function. Also, if you don't want to modify it at all and just want to super of clone, because clones protect it in the optic class. So you'll have to override it, even if you're not going to do anything fancy, but we need to do something special here. In the previous example, we didn't have any mutable properties, but our user it has a mutable property and the mutable property is our sensitive object. So the clone management is using this super dot clone and then, for all the mutual properties, it's going to create a clone as well. And the clone is doing nothing more than creating a shallow copy. So you have to do this for every object as mutable objects itself, because then the shallow copy is not enough. Luckily for us, it…
内容
-
-
-
-
-
(已锁定)
The problem of escaping references1 分钟 56 秒
-
(已锁定)
Collections and escaping references9 分钟 55 秒
-
(已锁定)
Avoiding escaping collection references6 分钟 36 秒
-
(已锁定)
Example custom objects: References on the loose2 分钟 9 秒
-
(已锁定)
Avoiding escaping references3 分钟 9 秒
-
(已锁定)
Solution: Fixing an escaping reference58 秒
-
(已锁定)
-
-