• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.arraycopy?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

i know this method gets copy of source array but it copies only rows and i would like to know is there any method similar to this one which can copy only columns for me or i have to write it for myself?

I wrote that kind of method ( not big deal anyway ) but i would like to know if there is such method in library?

P.S. i searched java api documentation but couldn't find anything...

kind regards

Igor
[ February 18, 2005: Message edited by: Igor Stojanovic ]
 
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you mean by rows and columns, but I don't know of any other Array copy method.
 
Igor Stojanovic
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is example what i want when i say copy aray and I specify number of columns...

This is "A" array:
1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2
1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2

when i say System.arraycopy(A, 0, B, 0, 3) I will get first 3 rows in my B array

B array :
1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2
1 2 3 4 5 6 7 8

but thats not what i want, i want method to copy first 3 columns so i can get in C array this:
1 2 3
9 8 7
1 2 3

I hope this explains what I mean

kind regards
Igor
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, arraycopy() works only on a single array. Note that multidimensional arrays are simply arrays of arrays -- not a single array with "rows" and "columns." You must roll your own code.

System.arraycopy() operates directly on the bytes in memory, simply copying one contiguous block of bytes to another location. Since "columns" of a two dimensional array are not contiguous in memory, it cannot be used.
 
reply
    Bookmark Topic Watch Topic
  • New Topic