<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Why String class is immutable?</title>
	<atom:link href="http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/</link>
	<description></description>
	<lastBuildDate>Wed, 10 Feb 2010 11:57:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Meher</title>
		<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/comment-page-1/#comment-20875</link>
		<dc:creator>Meher</dc:creator>
		<pubDate>Wed, 30 Sep 2009 08:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.hikrish.com/?p=25#comment-20875</guid>
		<description>I too agree with you Nishant. For a little efficient, they are contradicting the concepts of oops, inheritance. 

If we create an object using,
String str1 = new String(&quot;Hello&quot;)
2 objects will be created one in string constant pool, the other one in normal memory(heap) where all the objects are stored.

But, if we use..
String str2 = &quot;Hello&quot;
one literal will be created in string constant pool. All the remaining references point to the same string literal.</description>
		<content:encoded><![CDATA[<p>I too agree with you Nishant. For a little efficient, they are contradicting the concepts of oops, inheritance. </p>
<p>If we create an object using,<br />
String str1 = new String(&#8220;Hello&#8221;)<br />
2 objects will be created one in string constant pool, the other one in normal memory(heap) where all the objects are stored.</p>
<p>But, if we use..<br />
String str2 = &#8220;Hello&#8221;<br />
one literal will be created in string constant pool. All the remaining references point to the same string literal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nishant</title>
		<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/comment-page-1/#comment-69</link>
		<dc:creator>Nishant</dc:creator>
		<pubDate>Wed, 11 Jun 2008 12:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hikrish.com/?p=25#comment-69</guid>
		<description>Making String class as a immutable must be a big decision for java people. Only to create a string pool to optimize the processing does not define why the string class is immutable. For a very little efficiency they had contradicting the basic concepts of oops, inheritance. There are many other reason which are more probable than string pool answer. For example, if string is stored as a key in map, then nobody shall able to change the value of key. The string is immutable, you can&#039;t change the value. This could deifne one purpose of string being immutable.</description>
		<content:encoded><![CDATA[<p>Making String class as a immutable must be a big decision for java people. Only to create a string pool to optimize the processing does not define why the string class is immutable. For a very little efficiency they had contradicting the basic concepts of oops, inheritance. There are many other reason which are more probable than string pool answer. For example, if string is stored as a key in map, then nobody shall able to change the value of key. The string is immutable, you can&#8217;t change the value. This could deifne one purpose of string being immutable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sravan</title>
		<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/comment-page-1/#comment-47</link>
		<dc:creator>sravan</dc:creator>
		<pubDate>Thu, 17 Jan 2008 05:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hikrish.com/?p=25#comment-47</guid>
		<description>Hi &lt;br/&gt;&lt;br/&gt;Could you tell me. String class is immutable. If i want to do userdefined class also immutable class if it is possible how?</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>Could you tell me. String class is immutable. If i want to do userdefined class also immutable class if it is possible how?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: krishna</title>
		<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/comment-page-1/#comment-38</link>
		<dc:creator>krishna</dc:creator>
		<pubDate>Wed, 08 Aug 2007 12:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hikrish.com/?p=25#comment-38</guid>
		<description>Hi, as far as I know, only &quot;literal&quot; strings go to string pool (also the interned strings), however, I have no idea as to how the JVM garbage collects such strings in the pool. You have any idea as to where the string pool is placed ? whether the JVM heap or the native memory ?</description>
		<content:encoded><![CDATA[<p>Hi, as far as I know, only &#8220;literal&#8221; strings go to string pool (also the interned strings), however, I have no idea as to how the JVM garbage collects such strings in the pool. You have any idea as to where the string pool is placed ? whether the JVM heap or the native memory ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nasir</title>
		<link>http://www.hikrish.com/2006/07/15/why-string-class-is-immutable/comment-page-1/#comment-16</link>
		<dc:creator>Nasir</dc:creator>
		<pubDate>Thu, 05 Oct 2006 03:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hikrish.com/?p=25#comment-16</guid>
		<description>Hi &lt;br /&gt;&lt;br /&gt;What ever you said about string class of maintaining the pool and whenever we create a new string object it will refer in the pool is some what ambiguous.&lt;br /&gt;&lt;br /&gt;What i know is that&lt;br /&gt;&lt;br /&gt;We can create strings by two ways&lt;br /&gt;&lt;br /&gt;String str1 = new String(&quot;Hello&quot;) and&lt;br /&gt;String str2 = &quot;Hello&quot;&lt;br /&gt;&lt;br /&gt;Actually these two statements differ among themselves only in the manner how they are organized.&lt;br /&gt;&lt;br /&gt;Now when ever we create a string objecct without new keyword (str2) then JVM will first refer the string pool that is maintained by it for the same string by comparing with each other. If it matches then reference will automatically point to this place.&lt;br /&gt;Suppose if we create a string object with new keyword (str1) then JVM will never check the string pool and just it creates a new object in the heap and  the reference will be pointing to this place.&lt;br /&gt;&lt;br /&gt;That is what i know.&lt;br /&gt;Please correct me if I am wrong.&lt;br /&gt;&lt;br /&gt;One more thing to mention is we can make a string that is created with new keyword to be places in string pool with methoc intern() of string class.</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>What ever you said about string class of maintaining the pool and whenever we create a new string object it will refer in the pool is some what ambiguous.</p>
<p>What i know is that</p>
<p>We can create strings by two ways</p>
<p>String str1 = new String(&#8220;Hello&#8221;) and<br />String str2 = &#8220;Hello&#8221;</p>
<p>Actually these two statements differ among themselves only in the manner how they are organized.</p>
<p>Now when ever we create a string objecct without new keyword (str2) then JVM will first refer the string pool that is maintained by it for the same string by comparing with each other. If it matches then reference will automatically point to this place.<br />Suppose if we create a string object with new keyword (str1) then JVM will never check the string pool and just it creates a new object in the heap and  the reference will be pointing to this place.</p>
<p>That is what i know.<br />Please correct me if I am wrong.</p>
<p>One more thing to mention is we can make a string that is created with new keyword to be places in string pool with methoc intern() of string class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
