Results 1 to 4 of 4
Thread: immutable class
- 02-24-2013, 10:46 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 10
- Rep Power
- 0
-
Re: immutable class
Sorry, but this looks as if you're posting a homework or interview question directly from the assignment and asking for a "detailed explanation" as well which many find her to be unethical.
Rather than ask others to do your work, why not instead ask others to discuss it? What is your take on the answer to your question, and please support this answer as best you can.
- 02-24-2013, 10:56 PM #3
Member
- Join Date
- Feb 2013
- Posts
- 10
- Rep Power
- 0
Re: immutable class
hi
it is not for my homework,
honestly i have an exam and i want to be sure with its defenition
i searched alot over google without answer for it....
i just want to understand:
when i return a mutable variable over the get method, it return it by value, meaning that its exposed to exterior changes?
-
Re: immutable class
If you expose a mutable *reference* fields, then you risk changing the state of the immutable object. Your getter methods should return "defensive" copies of any reference fields.
This and other components of an immutable class are all well spelled out in most Google searches such as this hit in my search: Java Practices -> Immutable objects.
Best to read the tutorials that are available, and then come here to ask questions about points in the tutorials that confuse you, rather than ask us to re-write tutorials that are already easily available.
Similar Threads
-
mutable class extending into immutable class
By willemien in forum New To JavaReplies: 3Last Post: 09-13-2012, 09:26 PM -
How can I make this class immutable?
By fatabass in forum New To JavaReplies: 6Last Post: 12-18-2011, 10:08 PM -
how to write user defined class as Immutable?
By srinivasmallabathula in forum New To JavaReplies: 3Last Post: 07-04-2011, 11:50 PM -
What is Immutable in String
By elektronika in forum New To JavaReplies: 4Last Post: 12-10-2009, 12:58 PM -
What is an Immutable Class
By maheshkanda in forum New To JavaReplies: 3Last Post: 02-06-2009, 08:12 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks