课程: Java Memory Management: Values and References

今天就学习课程吧!

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

Primitives and objects in memory

Primitives and objects in memory

- [Instructor] Let's summarize all that we have seen so far with a bit of a bigger visualization example. We're going to visualize the creation of some custom objects, some primitive values, and we'll add in some strings, and also see some immutable objects. We'll see what all of this looks like in the heap and the stack memory. So this is our starting point. This is Java memory, and we see our stack memory on the left and our heap memory on the right. Our heap memory contains the string pool, and our stack memory shows that the main method was already started. So there is a block for the main method created. We then create two primitive values in our main method, an integer x with a value of five, and a Boolean b with the value of false. Then we'll be creating a string object. And the string is being inserted into the string pool, meaning what we just set, string food equals grapefruit in this case. Then, next up we're going to be creating a custom object. And a custom object is a…

内容