lLet’s clarify our
creation of objects in Java
•Instances
of a primitive type (int, float, etc.) are not references and don’t need to be created using new
•In fact,
we can’t create them using new (except for the case of an array of primitive types)
•When we
create an object of a user defined type (i.e., a class type) we are in fact creating references which means new must be used to actually allocate memory for the instance
of the type expected
•We can
then use references to an object using the (.) between the object reference and the member name:
•Objectreference.member
•