Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying 2D arrays

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hello I have to copy arrays many times

my array is this format
byte[][] myArray = new [3000][3000];

You can see that my arrays are quite large. I know there is a method copy array but I am on the understanding that this only for 1 dimensional arrays. I can copy the array using for loops. But.... is there a quick way to copy an array of this type [][]. By quicker I mean in processing time.

Cheers

Chris
 
You can use the clone method on the array to copy :

byte[][] myArray = new byte[3000][3000];
...
byte anotherArray[][] = (byte[][]) myArray.clone ();
...
 
I did not realise this. This is faster than copying manual I assume.
 
Apparently clone does not work for array objects
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top