<?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: Understanding Static Blocks</title>
	<atom:link href="http://isagoksu.com/2009/development/java/understanding-static-blocks/feed/" rel="self" type="application/rss+xml" />
	<link>http://isagoksu.com/2009/development/java/understanding-static-blocks/</link>
	<description>Nobody can be perfect, but you can think better, design better, and always use baby steps!</description>
	<lastBuildDate>Mon, 08 Mar 2010 17:05:53 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Isa Goksu</title>
		<link>http://isagoksu.com/2009/development/java/understanding-static-blocks/comment-page-1/#comment-3331</link>
		<dc:creator>Isa Goksu</dc:creator>
		<pubDate>Tue, 08 Sep 2009 19:27:14 +0000</pubDate>
		<guid isPermaLink="false">http://isagoksu.com/?p=225#comment-3331</guid>
		<description>&lt;p&gt;@abhishek, when you use multiple static keyword/block usages, JVM combines all of them into one big static block and then executes it. In your example static InitClass3 variable is already defined due to the fact that they&#039;re in the same block. This usage is exactly same with:&lt;/p&gt;

&lt;p&gt;static {
  ..
  public static InitClass3 refInitClass3= new InitClass3(2);
  System.out.println(”Hello You1″);
  refInitClass3= new InitClass3(1);
  System.out.println(”Hello You2″);
  ..
}&lt;/p&gt;

&lt;p&gt;Hope it helps.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@abhishek, when you use multiple static keyword/block usages, JVM combines all of them into one big static block and then executes it. In your example static InitClass3 variable is already defined due to the fact that they&#8217;re in the same block. This usage is exactly same with:</p>

<p>static {
  ..
  public static InitClass3 refInitClass3= new InitClass3(2);
  System.out.println(”Hello You1″);
  refInitClass3= new InitClass3(1);
  System.out.println(”Hello You2″);
  ..
}</p>

<p>Hope it helps.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Abhishek</title>
		<link>http://isagoksu.com/2009/development/java/understanding-static-blocks/comment-page-1/#comment-3330</link>
		<dc:creator>Abhishek</dc:creator>
		<pubDate>Tue, 08 Sep 2009 18:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://isagoksu.com/?p=225#comment-3330</guid>
		<description>&lt;p&gt;why this works (compiles) , even if the variable in static is yet not declared:&lt;/p&gt;

&lt;p&gt;public class StaticTest {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;static 
{
    System.out.println(&quot;Hello You1&quot;);
    refInitClass3= new InitClass3(1);
    System.out.println(&quot;Hello You2&quot;);       
}       
public InitClass2 refInitClass2= new InitClass2();  

public static InitClass1 refInitClass1= new InitClass1();

public static InitClass3 refInitClass3= new InitClass3(2);

public static void main(String[] args) {

    StaticTest refStaticTest = new StaticTest();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>why this works (compiles) , even if the variable in static is yet not declared:</p>

<p>public class StaticTest {</p>

<pre>

<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">static <br />
{<br />
&nbsp; &nbsp; System.out.println(&quot;Hello You1&quot;);<br />
&nbsp; &nbsp; refInitClass3= new InitClass3(1);<br />
&nbsp; &nbsp; System.out.println(&quot;Hello You2&quot;); &nbsp; &nbsp; &nbsp; <br />
} &nbsp; &nbsp; &nbsp; <br />
public InitClass2 refInitClass2= new InitClass2(); &nbsp;<br />
<br />
public static InitClass1 refInitClass1= new InitClass1();<br />
<br />
public static InitClass3 refInitClass3= new InitClass3(2);<br />
<br />
public static void main(String[] args) {<br />
<br />
&nbsp; &nbsp; StaticTest refStaticTest = new StaticTest();<br />
}</div></div>

</pre>

<p>}</p>]]></content:encoded>
	</item>
</channel>
</rss>
