<?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>Static &#8211; Jitendra Zaa</title>
	<atom:link href="https://www.jitendrazaa.com/blog/tag/static/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Mon, 05 Jul 2010 08:24:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>
<atom:link rel="search" type="application/opensearchdescription+xml" title="Search Jitendra Zaa" href="https://www.jitendrazaa.com/blog/wp-json/opensearch/1.1/document" />
<site xmlns="com-wordpress:feed-additions:1">87744916</site>	<item>
		<title>Static Block, Static Variable and Static Method</title>
		<link>https://www.jitendrazaa.com/blog/java/static-block-static-variable-and-static-method/</link>
					<comments>https://www.jitendrazaa.com/blog/java/static-block-static-variable-and-static-method/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Mon, 05 Jul 2010 08:24:42 +0000</pubDate>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Static]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=545</guid>

					<description><![CDATA[Infrormation about Static Block, Static Variable and Static Method in JAVA]]></description>
										<content:encoded><![CDATA[<p>In java the static keyword leads to following important   concepts  , namely</p>
<p>1) Static Variable</p>
<p>2) Static Block</p>
<p>3) Static Method</p>
<p><strong>Static   Variables</strong></p>
<p>Static variables are the special type of variable which are created during the load time of class, or we can say when the class is instantiated. The syntax for declaring variable as static is as follows,</p>
<p><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable.png?ssl=1"><img data-recalc-dims="1" fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-546" title="static Block Static Method Static Variable" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable.png?resize=502%2C102&#038;ssl=1" alt="static Block Static Method Static Variable" width="502" height="102" /></a></p>
<p>Some important points regarding static variables are</p>
<ol>
<li>It should be accessed by <strong>class name.</strong></li>
<li>Only one instance is created and it is shared by all the data members.</li>
</ol>
<p>This can be further explained as follows  . Consider an example consisting of static and Non static member</p>
<p><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable1.png?ssl=1"><img data-recalc-dims="1" decoding="async" class="aligncenter size-full wp-image-547" title="static Block Static Method Static Variable" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable1.png?resize=496%2C239&#038;ssl=1" alt="static Block Static Method Static Variable" width="496" height="239" /></a></p>
<p>In above example when class is instantiated multiple copies of instance variable k is created  where each copy would going to point a particular object at a  time, but in case of static only one copy is created and shared among all objects &amp; methods. As shown in fig</p>
<p><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable2.png?ssl=1"><img data-recalc-dims="1" decoding="async" class="aligncenter size-full wp-image-548" title="static Block Static Method Static Variable" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable2.png?resize=331%2C153&#038;ssl=1" alt="static Block Static Method Static Variable" width="331" height="153" /></a></p>
<div id="_mcePaste"><strong>Static Block:</strong></div>
<div id="_mcePaste">Static block&#8217;s are the block which are implicitly called when the class is instantiated that means when the instance of class is made. (by  using new operator)</div>
<p>Static Block:Static block&#8217;s are the block which are implicitly called when the class is instantiated that means when the instance of class is made. (by  using new operator)</p>
<p><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable3.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-549" title="static Block Static Method Static Variable" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable3.png?resize=433%2C164&#038;ssl=1" alt="static Block Static Method Static Variable" width="433" height="164" /></a></p>
<p class="MsoNormal" style="text-indent: .5in;">When the above program is executed , for each instance of class StaticBlockDemo static block is called , but keep in mind it is called only when the class is instantiated, not declared.</p>
<p class="MsoNormal"><strong style="mso-bidi-font-weight: normal;">Static Methods:</strong></p>
<p class="MsoNormal"><strong style="mso-bidi-font-weight: normal;">Some points about Static method<span style="mso-spacerun: yes;"> </span>are</strong></p>
<ol>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt &quot;Times New Roman&quot;;"> </span></span></span>Static methods are automatically created during load time of class.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt &quot;Times New Roman&quot;;"> </span></span></span>They are accessed by using class name.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt &quot;Times New Roman&quot;;"> </span></span></span>A single copy of static method is created and is shared among all other methods.</li>
<li><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;"><span style="font: 7.0pt &quot;Times New Roman&quot;;"> </span></span></span>The most important point <strong style="mso-bidi-font-weight: normal;">&#8220;Static function cannot access non static methods/memeber&#8221;</strong>.</li>
</ol>
<p class="MsoListParagraphCxSpLast">Declaration of static method is given as follows</p>
<p class="MsoListParagraphCxSpLast"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable4.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-550" title="static Block Static Method Static Variable" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/07/static-Block-Static-Method-Static-Variable4.png?resize=406%2C163&#038;ssl=1" alt="static Block Static Method Static Variable" width="406" height="163" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/java/static-block-static-variable-and-static-method/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">545</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-11-30 04:37:57 by W3 Total Cache
-->