How can I copy the content of a String array to another variable?
Hi all,
is it possible to copy directly the content of
the array rows[][] to another array?
String rows[][] = {
{"7268", "Cutter", "John", "Travel",""},
{"8133", "W. A.", "Thornhump", "C.E.O",""},
{"9923", "Berke", "Breathed", "Editor",""}
};
newArray = rows[][] ?
[342 byte] By [
mkreins] at [2007-9-26 1:18:01]

Yes, you can. But like this,String rows[][] = {{"7268", "Cutter", "John", "Travel",""},{"8133", "W. A.", "Thornhump", "C.E.O",""},{"9923", "Berke", "Breathed", "Editor",""}};String newArray [][] = rows;thanks,Srinivas.
This does not copy the content of the array, but merely sets the newArray reference to point to the same content as the original array. It may look like it is copying at first, but if you alter one of the "copies", you'll see that both references point to the same content.
If you want to copy content, you can use System.arraycopy or clone. If you do this, remember that these copies are always shallow, and will copy only the first level of the array, and not copy the subarrays or Strings. If you want a deep copy, you'll have to write a loop to do it.