A variable of a primitive type contains the actual data, not information on where the data is.
public class EgString { public static void main ( String[] args ) { String str; str = new String( "The Gingham Dog" ); System.out.println( str ); } }
Characteristics | |
---|---|
primitive variable | Contains the actual data. |
reference variable | Contains information on how to find the object. |
There are only eight primitive types, so there are only eight types of primitive variables.
In the above program, what is the object str
?