This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 24183
    
  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?
 
Similar Threads
arraycopy
System.arraycopy()
arraycopy() with String[][]
Java array help
How can I unite two arrays to one array?