CS202 Java-3
CS202 Introduction to Java
lIn Java, we treat everything as an object
•We can have objects of primitive types (like int, float, char) or objects of class types.
•Objects of primitive types can be created in the same way that we do in C++ (e.g.,   int object;)
•Objects of class types cannot be created this way.
•First, we must create identifiers for objects that we desire – these are actually references to objects
•Then, we must allocate memory on the heap for instances
•So, when we say:    List obj;   we have created only a reference not an object. If you want to send a message to obj (i.e., call a member function), you will get an error because obj isn’t actually pointing to anything:  List obj = new List();
•So, for a string object we could say:
•String s = “CS202!”; or
•String s = new String(“CS202!”);