[4011] in java-interest

home help back first fref pref prev next nref lref last post

Re: const

daemon@ATHENA.MIT.EDU (Elliotte Rusty Harold)
Thu Dec 7 12:16:12 1995

From: "Elliotte Rusty Harold" <Elliotte@blackstar.com>
To: java-interest@java.sun.com
Date:          Thu, 7 Dec 1995 09:53:39 EST
Reply-To: elliotte@blackstar.com
X-Confirm-Reading-To: elliotte@blackstar.com

> As far as I can see the C++ "const" keyword is not present in Java.
> In Java, how can you write an accessor function for a class data
> member that returns the data member object but doesn't allow callers
> to modify it? Was this deemed to be an unimportant feature of C++?
>

Declare the variable final, e.g.

public static final int myVar = 0

final variables can't be modified.

--
Elliotte Rusty Harold    Black Star Publishing Co., Inc.
elliotte@blackstar.com   116 East 27th Street
elharo@shock.njit.edu    NY NY 10016
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post