<?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>TechieDrill &#187; static</title>
	<atom:link href="http://techiedrill.com/tag/static/feed/" rel="self" type="application/rss+xml" />
	<link>http://techiedrill.com</link>
	<description>Your World Of Technical Tutorials</description>
	<lastBuildDate>Tue, 05 Jan 2010 16:50:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java Static ArrayCopy</title>
		<link>http://techiedrill.com/2009/11/java-static-arraycopy/</link>
		<comments>http://techiedrill.com/2009/11/java-static-arraycopy/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 16:40:43 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=456</guid>
		<description><![CDATA[Java offers a static ArrayCopy method from System class:
java.lang.System.arraycopy() method offers a convenient method to copy array elements from one array to another.
System.arraycopy(Object source_array, int source_position, 
Object destination_array, int destination_position, number_of_elements)
System.arraycopy() takes five parameters.
First parameter specifies the source_array from where the elements need to be copied.
Second parameter is the position(index) value of the source array [...]]]></description>
			<content:encoded><![CDATA[<p>Java offers a static <strong>ArrayCopy </strong>method from System class:</p>
<p><strong>java.lang.System.arraycopy()</strong> method offers a convenient method to copy array elements from one array to another.</p>
<p><em><strong>System.arraycopy(Object source_array, int source_position, </strong></em></p>
<p><em><strong>Object destination_array, int destination_position, number_of_elements)</strong></em></p>
<p>System.arraycopy() takes five parameters.</p>
<p>First parameter specifies the source_array from where the elements need to be copied.</p>
<p>Second parameter is the position(index) value of the source array from what index array is to be copied.</p>
<p>Third parameter specifies the destination array to which array the values need to be copied. Fourth parameter specifies the destination array starting index.</p>
<p>Fifth parameter specifies the numberOfElements need to be copied from source array to destination array.</p>
<p>Check out your understanding with below example.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import java.io.*;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class Student</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>int b[] = new int[5];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Student(int[] a)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">System.arraycopy(a,0,b,0,5);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>void Display()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i=0;i&lt;5;i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(b[i]);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class StudentClass</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String [] args) throws IOException</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>DataInputStream dis = new DataInputStream(System.in);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>int a[] = new int[5];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.print(&#8221;Enter marks : &#8220;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i=0;i&lt;5;i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>a[i]=Integer.parseInt(dis.readLine());</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Student st = new Student(a);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>st.Display();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p><em>import java.io.*;</em></p>
<p><em>class Student</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>int b[] = new int[5];</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>Student(int[] a)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><em>System.arraycopy(a,0,b,0,5);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>void Display()</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>for(int i=0;i&lt;5;i++)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.println(b[i]);</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
<p><em>class StudentClass</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>public static void main(String [] args) throws IOException</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>DataInputStream dis = new DataInputStream(System.in);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>int a[] = new int[5];</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.print(&#8221;Enter marks : &#8220;);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>for(int i=0;i&lt;5;i++)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>a[i]=Integer.parseInt(dis.readLine());</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>Student st = new Student(a);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>st.Display();</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/java-static-arraycopy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Java Static block/variables/method</title>
		<link>http://techiedrill.com/2009/11/understanding-java-static-blockvariablesmethod/</link>
		<comments>http://techiedrill.com/2009/11/understanding-java-static-blockvariablesmethod/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 18:18:51 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[Variables]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=433</guid>
		<description><![CDATA[lass UseStatic
{
 static int a=3;
 static int b;
 static void meth(int x)
 {
 System.out.println(&#8221;x: &#8220;+x);
 System.out.println(&#8221;a: &#8220;+a);
 System.out.println(&#8221;b: &#8220;+b);
 }
 static
 {
 System.out.println(&#8221;static block initialized: &#8220;);
 b=a*4;
 }
 public static void main(String [] args)
 {
 meth(42);
 }
}
Static block/variables/methods are very powerful in java.
When we say static it is static throughout the application. If you declare [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>lass UseStatic</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>static int a=3;</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>static int b;</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>static void meth(int x)</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;x: &#8220;+x);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;a: &#8220;+a);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;b: &#8220;+b);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>static</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;static block initialized: &#8220;);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>b=a*4;</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>public static void main(String [] args)</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>meth(42);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>}</em></div>
<p><strong>Static block/variables/methods are very powerful in java.</strong></p>
<p>When we say static it is static throughout the application. If you declare a static variable in a stand-alone application, the life of the variable will be throughout the end of the application but in the case of the web application, static variable  has life till the web server is stopped.</p>
<p>Static variables are executed at first the program runs. Next the static block is executed. Static methods are executed when a call is raised.</p>
<p><em>Note: Static methods can call only static methods. To call non-static methods instance of the class should be created</em></p>
<p><strong>Refer below code for better understanding</strong></p>
<p><em>class UseStatic</em></p>
<p><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>static int a=3;</em></p>
<p><span style="white-space:pre"><em> </em></span><em>static int b;</em></p>
<p><em><br />
</em></p>
<p><span style="white-space:pre"><em> </em></span><em>static void meth(int x)</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.out.println(&#8221;x: &#8220;+x);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.out.println(&#8221;a: &#8220;+a);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.out.println(&#8221;b: &#8220;+b);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>static</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.out.println(&#8221;static block initialized: &#8220;);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>b=a*4;</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>public static void main(String [] args)</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>meth(42);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/understanding-java-static-blockvariablesmethod/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
