We did an in-class code demo in this class. See the lecture code
repository for this section for the completed example.
Today's example showed,
- how to declare a local variable,
chapter1.Terrarium myTerrarium;
- how assign a value to a variable,
myTerrarium = new chapter1.Terrarium();
- to call a method on the object referred to by the variable,
myTerrarium.add(new chapter1.Ant())
- explained that the value of a new + constructorexpression
is a reference to an object,
- explained that object references can be stored in variables, and
- the value of a variable is the reference it stores.