File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How do to use ArrayCopy? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do to use ArrayCopy?" Watch "How do to use ArrayCopy?" New topic
Author

How do to use ArrayCopy?

Travis Gn
Greenhorn

Joined: Sep 11, 2003
Posts: 19
I tried copying arrays:
array1 = array2;
It's not working. Someone said to copy an array you need to use Arraycopy I don't know how to use this? Any help?


I need more help!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Assigning array1=array2 will, as you have probably already figured out, just give you two pointers to the same array.
To copy any array, you can use the static method arraycopy() in the java.lang.System class, like this:

To find out what the various parameters mean, see the Javadoc for this method.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do to use ArrayCopy?