课程: Java Memory Management: Values and References
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Avoiding escaping collection references - Java教程
课程: Java Memory Management: Values and References
Avoiding escaping collection references
- [Instructor] So, we just created a copy to deal with escaping references of collections. But we can also do something different. We can create an unmodifiable collection. This way we are using a special method, actually, one of the special methods, to create a collection that can not be altered. This will solve the problem for collections with immutable objects as a build in Java solution. This way the collections can not be modified. And if there are immutable objects on there, well, they can not be changed anyways. So there's no problem anymore. But it doesn't solve the escaping references of immutable objects on collections though. Let's have a look at how to create unmodifiable collections in IntelliJ. So, where we created the copy we now just send all the product's objects to a new array list. I'm going to do something different right now. I'm going to be returning an unmodifiable list. And I can use the list or the collection's interface to do this. Let me show you two ways of…
内容
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-