A good answer might be:

A variable of a primitive type contains the actual data, not information on where the data is.


Two Kinds of Variables

An object reference does not contain the actual data, just a way to find it. There are two kinds of variables in Java:

 Characteristics
primitive variableContains the actual data.
reference variableContains information on how to find the object.

Here is the example program again:


class egString
{

  public static void main ( String[] args )
  {
    String str;
    
    str = new String( "The Gingham Dog" );

    System.out.println( str );
  }
}

When the line

System.out.println( str );

is executed (when the program is running), the information stored in str is used to go to the object and get the data to be printed.

QUESTION 6:

Does using str in the above statement change the information in it?