<?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; copy</title>
	<atom:link href="http://techiedrill.com/tag/copy/feed/" rel="self" type="application/rss+xml" />
	<link>http://techiedrill.com</link>
	<description>Your World Of Technical Tutorials</description>
	<lastBuildDate>Tue, 10 Aug 2010 20:39: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>
	</channel>
</rss>
