CS202 Introduction to Java
When we create a reference, we want to connect it to a new
object
String s = new String (“CS202!”);   //or
List obj = new List();   //default constructor…
We do this with the new keyword
This allocates memory for a new string and provides an
initial value for the character string
And, like in C++ this causes the constructor for the class type
to be implicitly invoked
New places the objects on the heap (which is not as flexible
as allowing objects to be allocoated on the stack)
It is not possible to request local objects of a class or to pass
objects of a class by value to a function (or as the return
value). This is because we are always working with a
reference to the object – which is what gets passed (by value)