Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Jun 14, 2006

Using System.arraycopy(.....)

When you need the contents of an array for processing, you no longer have to write loops to copy the required contents from the main to the sub-array. Java has provided an API for this task—the arraycopy method in the System class.
The method takes five arguments:
  1. src: The source array.
  2. srcPosition: The position in the source from where you wish to begin copying.
  3. des: The destination array.
  4. desPosition: The position in the destination array to where the copy should start.
  5. length: The number of elements to be copied.
This method throws a NullPointerException if either of src or des are null.

It also throws an ArrayStoreException in the following cases:

  • If the src is not an array.
  • If the des is not an array.
  • If src and des are arrays of different data types.
MS Sridhar
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap