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 Copying array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Copying array" Watch "Copying array" New topic
Author

Copying array

Ruslan Ivanov
Ranch Hand

Joined: Feb 22, 2001
Posts: 72
hello , i am having problem with System.arraycopy() method i am getting NullPointerExceptions with it. What i want to do is just to copy a few elements from one array to another so this method seems convinient for me. I know i can do this by hand myself but if it's there for me why not use it.
Here is what i tried and failed.

thanks.

[This message has been edited by Ruslan Ivanov (edited June 27, 2001).]
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Change
String copy[];
to
String copy[] = new String[#];
where # is the size you want to make the second array and it will work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Copying array
 
Similar Threads
returning an array
Anonymous Arrays
toArray()
Multidimensional array copy
arrayindexoutofbound exception