<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hello Thupten &#187; &#187; if statement</title>
	<atom:link href="https://www.thupten.feedback/tag/if-statement/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.thupten.feedback</link>
	<description>Just another developer&#039;s blog</description>
	<lastBuildDate>Sat, 20 Jun 2026 21:18:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>If statement is not always followed by a condition in java</title>
		<link>https://www.thupten.feedback/2014/01/14/if-statement-is-not-followed-by-a-condition-in-java/</link>
		<comments>https://www.thupten.feedback/2014/01/14/if-statement-is-not-followed-by-a-condition-in-java/#respond</comments>
		<pubDate>Tue, 14 Jan 2014 21:02:53 +0000</pubDate>
		<dc:creator><![CDATA[thupten]]></dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[if statement]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hellothupten.com/?p=594</guid>
		<description><![CDATA[This code will compile and run. Notice the assignment operator(=) in the condition. boolean a; boolean b = true; if(a=b){ //do anything; //this compiles } But this won&#8217;t compile int a; int b = 5; if(a=b){ //notice its still = not == //do anything; //this does not compile } The reason is because the previous [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This code will compile and run. Notice the assignment operator(=) in the condition.</p>
<pre name="code" class="java">
boolean a;
boolean b = true;
if(a=b){
   //do anything;
   //this compiles
}
</pre>
<p>But this won&#8217;t compile</p>
<pre name="code" class="java">
int a;
int b = 5;
if(a=b){   
   //notice its still = not ==
   //do anything;
   //this does not compile
}
</pre>
<p>
The reason is because the previous code&#8217;s a is of <pre>boolean</pre> type and the latter&#8217;s is of <pre>int</pre> type.
</p><p>
<pre>if</pre> statement is not necessarily followed by a condition. <pre>a=b</pre> is not a condition. Its an assignment. But it works if the left variable (i.e. a) is of a boolean type.
</p><p>
So its better if we think <pre>if(boolean)</pre> instead of <pre>if(condition)</pre>. Anyway, a condition like <code>a==b</code> or <code>a>b</code> etc will result a boolean result.
</p>]]></content:encoded>
			<wfw:commentRss>https://www.thupten.feedback/2014/01/14/if-statement-is-not-followed-by-a-condition-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
