课程: Java Memory Management: Values and References

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

The problem of escaping references

The problem of escaping references

- [Instructor] At this point, you already know what pass by reference means. We have seen this when we called the method with an object as an argument. Reference to this object was sent. And whenever the method modified this object, this meant that the object was also modified for other places in our code that we're holding the same reference. Since they are both pointing to the very same object. Whoever has the reference can access the object. So no news there, but this passing by reference is also true for returning objects from methods. Reference to the object gets sent. And this can also happen to third-party libraries in your application for example. Whenever this happens without it being your intention, we call this escaping references. Sending an object reference unintentionally with possible negative side effects. Even though this might be not too surprising to you, security breaches that this behavior of Java can cause, they might be a surprise. Let's move over to IntelliJ…

内容