<?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: 3 ways to initialize class attributes in Java</title>
	<atom:link href="http://www.phpmag.ru/2009/07/22/3-ways-to-initialize-class-attributes-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmag.ru/2009/07/22/3-ways-to-initialize-class-attributes-in-java/</link>
	<description>Phrozn, Phing &#38; Zend Framework Musings</description>
	<lastBuildDate>Tue, 15 Nov 2011 15:38:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Dushan Hanuska</title>
		<link>http://www.phpmag.ru/2009/07/22/3-ways-to-initialize-class-attributes-in-java/comment-page-1/#comment-471</link>
		<dc:creator>Dushan Hanuska</dc:creator>
		<pubDate>Fri, 24 Jul 2009 03:43:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpmag.ru/?p=695#comment-471</guid>
		<description>As KD said above, the static initialization block is most commonly used to initialize &quot;constant&quot; Maps and Collections. For example:

private static final List COLORS;
static {
  List colors = new ArrayList();
  colors.add(&quot;red&quot;);
  colors.add(&quot;yellow&quot;);
  colors.add(&quot;blue&quot;);
  COLORS = Collections.unmodifiebleList(colors);
}</description>
		<content:encoded><![CDATA[<p>As KD said above, the static initialization block is most commonly used to initialize &#8220;constant&#8221; Maps and Collections. For example:</p>
<p>private static final List COLORS;<br />
static {<br />
  List colors = new ArrayList();<br />
  colors.add(&#8220;red&#8221;);<br />
  colors.add(&#8220;yellow&#8221;);<br />
  colors.add(&#8220;blue&#8221;);<br />
  COLORS = Collections.unmodifiebleList(colors);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KD</title>
		<link>http://www.phpmag.ru/2009/07/22/3-ways-to-initialize-class-attributes-in-java/comment-page-1/#comment-468</link>
		<dc:creator>KD</dc:creator>
		<pubDate>Thu, 23 Jul 2009 09:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpmag.ru/?p=695#comment-468</guid>
		<description>Good post. One useful case of initialization blocks I have found is in initializing maps &amp; lists, eg:

Map myMap = new HashMap(){
  { 
    put(&quot;Name&quot;, &quot;A Name&quot;);
    put(&quot;Age&quot;, 40);
  }
};

etc.</description>
		<content:encoded><![CDATA[<p>Good post. One useful case of initialization blocks I have found is in initializing maps &amp; lists, eg:</p>
<p>Map myMap = new HashMap(){<br />
  {<br />
    put(&#8220;Name&#8221;, &#8220;A Name&#8221;);<br />
    put(&#8220;Age&#8221;, 40);<br />
  }<br />
};</p>
<p>etc.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

