Date:
Wed, 12 Apr 2000 23:27:22 +1000
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset="iso-8859-1"
|
From: "Geoff Bull" <[log in to unmask]>
> > a = 1;
> > b = a;
> > a = a+1;
> >
> > what does b equal?
>
> 1
>
> > In Java:
> > if b is the primitive "int", then b=a-1
> > if b is the class "Integer" then b = a means in Ada terms b renames a.
For which
> > we can thank C.
>
> But b must have been a primitive, because operators only work for
primitives
> (except for "+" for catenating Strings).
>
> Have I missed something?
Of course you're right. As they say in the classics, DOH!
My example was too simple, I was careless, should have had a = f(a) not a=
a+1.
where the signature of f is not immediately visible (to humans, rather than
the machine).
The problem I was attempting to illustrate is the somewhat counter-intuitive
use of
=, where on a Class it's a rename, on a primitive it's an assignment of
value.
Similarly for a==b, where in java you're saying "are a and b just aliases
for the same object"
rather than comparing their internal values. Which is done with a.equals(b),
assuming
that's defined.
Mea Culpa in any event. Thanks for the correction and peer review.
|
|
|