PPT Slide
- To make the reference shoeBox be not null,
it is necessary to instantiate it, e.g.,
When Java encounters the keyword “new”, it allocates space in memory for an instance of that object. Now, shoeBox refers to an instance of class Box, i.e., an object.
Note that the instance (or object) “gets” everything defined in class Box. It has unique copies of all the variables. (The methods are shared between all instance of the class, but Java knows which instance you are referring to.)