[4029] in java-interest
Re: final keyword usage
daemon@ATHENA.MIT.EDU (R.Volkmann)
Thu Dec 7 22:06:39 1995
Date: Thu, 7 Dec 95 12:52:43 -0600
From: "R.Volkmann" <m224873@ws1768.mdc.com>
To: darcy@arcs.bcit.bc.ca
Cc: java-interest@java.Eng.Sun.COM
In-Reply-To: <30C72F94.6B07@arcs.bcit.bc.ca> (darcy@arcs.bcit.bc.ca)
Reply-To: "R. Mark Volkmann"<m224873@svmstr01.mdc.com>
>Date: Thu, 07 Dec 1995 10:16:52 -0800
>From: D'Arcy Smith <darcy@arcs.bcit.bc.ca>
>
>R.Volkmann wrote:
>
>> Which of the following are valid uses of "final"?
>>
>> - used to declare that a function argument will not be modified
>>
>> class City {
>> public float milesTo(final City destinationCity) { ... }
>> ...
>> }
>invalid.
Is there any way to stop a method from changing the attributes of an object
which is passed to it as an argument?
>> - used to prevent callers from changing an object returned from a function
>>
>> class Foo {
>> public final String data() { return data_; }
>> protected String data_;
>> }
>valid syntax but ... "A method that is declared final cannot be overridden".
Is there any other way to stop the caller of a method from changing the
attributes of an object that is returned from the method?
|------------------------------------------------------------|
| R. Mark Volkmann - Principal Specialist Programmer/Analyst |
| McDonnell Douglas Aerospace, St. Louis, Missouri, USA |
| email m224873@svmstr01.mdc.com, voice (314)232-0498 |
|------------------------------------------------------------|
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com