tag:blogger.com,1999:blog-646266935504215225.post8679064771707354918..comments2023-04-04T20:27:57.262+05:30Comments on Roy's Technology Diary: Is Java String really immutable...?Rahul Royhttp://www.blogger.com/profile/11252266738435830339noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-646266935504215225.post-78762588846813170132009-04-29T12:09:00.000+05:302009-04-29T12:09:00.000+05:30Hi, thanks for sharing your views. I do agree that...Hi, thanks for sharing your views. I do agree that using reflection here in this case is a cheat. However, it does make one thing clear here, i.e. the Java String is just not a perfect immutable class, going as per the core definition of it. :) Ideally, if one states a class to be immutable then, no matter what, it's state (even that of private attributes) should not be changed/altered after its once constructed.Rahul Royhttps://www.blogger.com/profile/11252266738435830339noreply@blogger.comtag:blogger.com,1999:blog-646266935504215225.post-59307531929676995952009-04-27T22:27:00.000+05:302009-04-27T22:27:00.000+05:30The private field "hash" does not hold any state i...The private field "hash" does not hold any state information, it is merely a cache of the hashCode() return value. No method return value or behavior will be affected by the fact that hash is set or not.<br />Also, using reflection to access private fields is a bit cheating ;-)vivihttps://www.blogger.com/profile/17418896573852176847noreply@blogger.com