Primitive types are not classes, and so primitives contain a single piece of data and do not contain methods. So, you cannot call methods on primitives. As an optimization, if two String literals have the same value, Java will create just one String to be shared. This optimization is specific to Strings. Information about this behavior is available in the Java Language Specification section on String Literals .
Immutable objects have a value that is defined upon creation.
After the object is created, the value will never change. Mutable objects have dynamic state that can change over time. The elements of a vector can change over time, so the Vector class in Java is mutable. Back to Index Card Answers . Back to the 6.170 home page .