课程: Java Memory Management: Values and References

今天就学习课程吧!

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

Objects

Objects

- [Instructor] Objects are a bundle of values. As opposed to primitives, objects get stored on the heap, and the address to the place on the heap gets stored on the stack, else we'd have no way to get the values from the heap. This address is simply called an object reference. The memory block for the objects on the heap is a lot like the stack. Primitive values are stored on it directly, and other objects are referenced with an object reference. There are very many built-in Java objects that we can use such as ArrayList and all the other objects in the collection framework, all the wrapper classes for primitives, such as the integer and double. We have string, thread, and so many more, but we could also create our own objects, and these objects will also get stored on the heap. Let's move over to IntelliJ and revisit our previous example. All right, on line 13 and 14, you can see that I'm creating a new person and a new address, and the person reference I'm storing in the variable p,…

内容