Re: Strings...immutable?
Patricia Shanahan <pats@acm.org> writes:
C pointers can point to pointers, without them being wrapped in a struct
or array. Java references cannot point to other unwrapped Java
references, so Java pointers are not C pointers.
In C, a pointer can point /only/ to objects, just as in Java.
In C, any storage location with a type is called an ?object? -
this is called ?variable? in Java.
For example, in C, in the compound-statement
{ int * a = 0; int * * b = &a; }
the name ?a? is the name of an object.
By this language-specific interpretation of both terms,
the statement literally holds again in both languages.
In both languages, an object is what can be referred to by
a pointer.
~
The notion ?pointer? actually is an abbreviation, but this
usage sometimes leads to confusion.
?pointer? might mean
- ?pointer value? (like ?0? in C or ?null? in Java) or
- a storage location containing a pointer value
(a ?reference variable? in Java, or a ?pointer object? in C)
In the above compound-statement, b points to a pointer
/storage location/ (called an ?object? in C, or ?variable? in
Java), which then in turn contains a pointer /value/ (here, 0).