Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
mutate an object or create a new one?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ingo R. Homann, post: 1999454"] Hi, No, I think, the 2-class-design is better: Consider you have a method that wants to indicate that it does not change the Parameter: void foo(UnmodifiableInt i) {...} Now, why should it be impossible to pass a ModifiableInt to that method? And vice versa: Consider a method is returning an ModifiableInt: ModifiableInt foo() {...} Why should it be impossible to assign the returned value to a variable of type UnmodifiableInt to document that the variable will not be modified? Ciao, Ingo [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
mutate an object or create a new one?
Top