<?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: Java String comparison. The difference between == and equals().</title>
	<atom:link href="http://www.zparacha.com/java-string-comparison/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zparacha.com/java-string-comparison/</link>
	<description>Effective programming and blogging tips by Zaheer Paracha</description>
	<lastBuildDate>Sat, 11 Feb 2012 03:00:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Erinyes</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1944</link>
		<dc:creator>Erinyes</dc:creator>
		<pubDate>Mon, 30 Jan 2012 14:07:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1944</guid>
		<description>Wow, I never knew that _this_ is the difference between both compare operations. Thanks for the info! Much appreciated :D</description>
		<content:encoded><![CDATA[<p>Wow, I never knew that _this_ is the difference between both compare operations. Thanks for the info! Much appreciated <img src='http://www.zparacha.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sandesh</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1927</link>
		<dc:creator>sandesh</dc:creator>
		<pubDate>Thu, 26 Jan 2012 10:05:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1927</guid>
		<description>thanx a lot ......... i was breaking my head  as i did the same mistake of confusing == ........
your article helped .........</description>
		<content:encoded><![CDATA[<p>thanx a lot &#8230;&#8230;&#8230; i was breaking my head  as i did the same mistake of confusing == &#8230;&#8230;..<br />
your article helped &#8230;&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Leo Nardus</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1771</link>
		<dc:creator>Leo Nardus</dc:creator>
		<pubDate>Wed, 23 Nov 2011 20:40:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1771</guid>
		<description>Hi .. Thanks mate for your posting .. 
It&#039;s help me a lot :D ..
Love it ..</description>
		<content:encoded><![CDATA[<p>Hi .. Thanks mate for your posting ..<br />
It&#8217;s help me a lot <img src='http://www.zparacha.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ..<br />
Love it ..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1753</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Wed, 16 Nov 2011 11:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1753</guid>
		<description>Before reding your post i had confision to use these operators. Now i got clear idea. Thanks for your post..</description>
		<content:encoded><![CDATA[<p>Before reding your post i had confision to use these operators. Now i got clear idea. Thanks for your post..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pajarito</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1724</link>
		<dc:creator>Pajarito</dc:creator>
		<pubDate>Fri, 21 Oct 2011 11:18:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1724</guid>
		<description>So, what is the diff between:

String a = &quot;abc&quot;;
String a = new String(&quot;abc&quot;);

Beacuse &quot;everything in Java is an object&quot; the first one above is an object of String class, the same as the latter. Is there any difference?</description>
		<content:encoded><![CDATA[<p>So, what is the diff between:</p>
<p>String a = &#8220;abc&#8221;;<br />
String a = new String(&#8220;abc&#8221;);</p>
<p>Beacuse &#8220;everything in Java is an object&#8221; the first one above is an object of String class, the same as the latter. Is there any difference?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nascar</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1695</link>
		<dc:creator>Nascar</dc:creator>
		<pubDate>Sat, 01 Oct 2011 07:02:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1695</guid>
		<description>Or can we say?
If (!month.equals(“J”, “F”,“A”)) {
Perform error validation;
 }</description>
		<content:encoded><![CDATA[<p>Or can we say?<br />
If (!month.equals(“J”, “F”,“A”)) {<br />
Perform error validation;<br />
 }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nascar</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1694</link>
		<dc:creator>Nascar</dc:creator>
		<pubDate>Sat, 01 Oct 2011 06:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1694</guid>
		<description>Hi,

Thanks for the post. I am just a beginner in Java.

I need to know how to validate multiple values for a string.
like, if the value of month is not equal to J or F or M, perform some error handling. 
The requirement is: J, F and M are the expected (good) values for month.

Example:  If (!month.equals(&quot;J&quot;) &#124;&#124; !month.equals(&quot;F&quot;) &#124;&#124;  !month.equals(&quot;A&quot;)) {
          Perform error validation;
          }

Is the above correct?

Any help is appreciated.  Thanks</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for the post. I am just a beginner in Java.</p>
<p>I need to know how to validate multiple values for a string.<br />
like, if the value of month is not equal to J or F or M, perform some error handling.<br />
The requirement is: J, F and M are the expected (good) values for month.</p>
<p>Example:  If (!month.equals(&#8220;J&#8221;) || !month.equals(&#8220;F&#8221;) ||  !month.equals(&#8220;A&#8221;)) {<br />
          Perform error validation;<br />
          }</p>
<p>Is the above correct?</p>
<p>Any help is appreciated.  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1693</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Fri, 30 Sep 2011 19:07:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1693</guid>
		<description>Ok, the equals() method makes sense, but what if you cant use the == or &lt;= to compare a variable? How do you use equals() to test a range of values, assuming you can at all?</description>
		<content:encoded><![CDATA[<p>Ok, the equals() method makes sense, but what if you cant use the == or &lt;= to compare a variable? How do you use equals() to test a range of values, assuming you can at all?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom N.</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1683</link>
		<dc:creator>Tom N.</dc:creator>
		<pubDate>Mon, 26 Sep 2011 20:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1683</guid>
		<description>I haven&#039;t looked at the Java source code, but my educated guess is that the Java run time is placing all the constant strings (i.e. &quot;abc&quot;) at specific locations in memory, and then assigning the pointers (i.e. s1) to point to those locations. Both of the &quot;abc&quot; constants, being equal,  would (as a optimization) be assigned to the same location,  Since s1 was assigned to point to that location, s1 == &quot;abc&quot; will be true. If you built up the string &quot;abc&quot; in another fashion, this would not be the case,

   Tom</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t looked at the Java source code, but my educated guess is that the Java run time is placing all the constant strings (i.e. &#8220;abc&#8221;) at specific locations in memory, and then assigning the pointers (i.e. s1) to point to those locations. Both of the &#8220;abc&#8221; constants, being equal,  would (as a optimization) be assigned to the same location,  Since s1 was assigned to point to that location, s1 == &#8220;abc&#8221; will be true. If you built up the string &#8220;abc&#8221; in another fashion, this would not be the case,</p>
<p>   Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Naveen</title>
		<link>http://www.zparacha.com/java-string-comparison/comment-page-1/#comment-1682</link>
		<dc:creator>Naveen</dc:creator>
		<pubDate>Mon, 26 Sep 2011 13:28:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.zparacha.com/?p=1250#comment-1682</guid>
		<description>String s1=&quot;abc&quot;;

if(s1==&quot;abc&quot;){
System.out.println(&quot;Both are Equal&quot;);
}else{

System.out.println(&quot;Both are not Equal&quot;);
}

Output:- Both are Equal

How this can Happen can any one please explain ?</description>
		<content:encoded><![CDATA[<p>String s1=&#8221;abc&#8221;;</p>
<p>if(s1==&#8221;abc&#8221;){<br />
System.out.println(&#8220;Both are Equal&#8221;);<br />
}else{</p>
<p>System.out.println(&#8220;Both are not Equal&#8221;);<br />
}</p>
<p>Output:- Both are Equal</p>
<p>How this can Happen can any one please explain ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

