I am trying to understand the three steps of object declaration, creation and assignment, and want to know if what I wrote about the picture is correct (from Head First Java, but edited text below to use my own words and see if I can explain it properly):
1) Declare a reference variable
Dog myDog
Here we tell JVM to make space for a reference variable. This reference can only EVER be a type Dog from now on.
myDog is the name we give the reference variable, to make it more readable and usable for us.
Beneath myDog is actually a bunch of bits representing a way to get to the actual object on the heap (e.g. @Dog1234 fx). NOT SURE if this is true
2) Create an object
new Dog();
Here we tell JVM to make space for a new Object instance on the Heap. Its the actual Dog object that is stored somewhere in the heap by a certain address (e.g. @Dog1234).
3) Link the object and reference
=
Last part is to assign the new Dog() we created on the heap to the reference variable myDog. In other words, we make sure that the reference variable we call myDog is connected to the actual new Dog() we created, and therefore are able to control the object on the heap through this reference variable myDog.