Print

Print


[log in to unmask] wrote:

> Another problem is Java's lack of information hiding (though you *can* get the
> same problem in Ada, it's more difficult)
>
> viz in the code fragment,
>
>    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?

> If b is a primitive, you can't do text output of it.

int b = 5;
System.out.println ("" + b);
// this prints a line with a 5 on it

Cheers
Geoff