Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Copying array

 
Ruslan Ivanov
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change
String copy[];
to
String copy[] = new String[#];
where # is the size you want to make the second array and it will work.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!