A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Originally posted by saikrishna cinux:
i know about immutable concept
immutable means we cannot change the state of an object
i think we can achive this by using private fileds in a class
is Maths class immutable?
Originally posted by saikrishna cinux:
is there any other way to create immutable class?
am i right ?
42
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
The Best way to predict your future is to create it - Every great individual common man
Originally posted by Ankur Sharma:
Well I don't know what you are thinking but according to me The class which is final is called as immutable.
Immutable means which cann't be change further.
So once you declare the class as final You cann't extend it..
That makes the class immutable.
If I am wrong then please correct me..
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Ankur Sharma:
and yes most important is
Not to provide any direct access to fields, and keep private all methods that alter the state of the object.
If I am wrong then please correct me..
The Best way to predict your future is to create it - Every great individual common man
why string class is said to be immutable ?
SCJP 1.5
"I'm not back." - Bill Harding, Twister
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Tony Morris:
ln -s referential_transparency immutable_questions
The Best way to predict your future is to create it - Every great individual common man
Originally posted by Ankur Sharma:
what's this Tony??
Could you come up with details what do you mean by above..
Tony Morris
Java Q&A (FAQ, Trivia)
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
"I'm not back." - Bill Harding, Twister
Originally posted by Rusty Shackleford:
Is the context of the original question, a mathematical background is not necessary to explain nor understand. It is like a college algebra or calculus course, an intuitive understanding of a function is all that you need. Not long after calculus that understanding is not useful and a more rigorous one is needed. Not that a rigorous definition of a function is all that difficult to understand.
[ August 24, 2006: Message edited by: Rusty Shackleford ]
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Stan James:
Is a class immutable if some of its members are mutable and accessible by get? Surely not using Tony's referential transparency as you could call one method twice and get different results. So all private variables and no set methods is not enough yet. I'm liking Tony's test for immutable better all the time, though it doesn't mechanically translate into how to code one.
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Paul Clapham:
Okay. So, for example, is java.util.Random immutable? It doesn't have any "setter" methods, or any other method whereby other classes could affect the state of a Random object, as far as I can see. But it thoroughly fails the referential transparency test.
Edit: I didn't look and think hard enough. Clearly the methods nextInt() and nextDouble() and so on are setter methods, even though no information is passed by the callers of those methods.
[ August 24, 2006: Message edited by: Paul Clapham ]
Tony Morris
Java Q&A (FAQ, Trivia)
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |