Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Taking values out of one array and putting them into another.

    Quote Originally Posted by Norm View Post
    That looks like you don't know what you are doing. And it is confusing to read.
    i originally had this:
    Java Code:
    System.arraycopy(list,pos_list,zips,pos_zips,1);
    zips[pos_zips] = list[pos_list];
    but did some googling on copying arrays and came up with
    Java Code:
    System.arraycopy(list,pos_list,zips,pos_zips,1);
    They both work, i just did it with both of them. Is there any reason I would choose the simple assignment over using arraycopy or vice versa? I understand that the assignment is easier to read, but then why bother having an arraycopy method?

  2. #22
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Taking values out of one array and putting them into another.

    arraycopy is for more than 1 element.

  3. #23
    Wnt2bsleepin is offline Senior Member
    Join Date
    Feb 2012
    Posts
    219
    Rep Power
    3

    Default Re: Taking values out of one array and putting them into another.

    Ok, makes sense. The fact that it is easier to read also makes it worth not using arraycopy. Thank you.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Values in Array
    By jazob in forum New To Java
    Replies: 2
    Last Post: 12-10-2011, 01:29 AM
  2. taking something from an array.
    By shazakala in forum New To Java
    Replies: 1
    Last Post: 05-10-2011, 01:36 AM
  3. Replies: 14
    Last Post: 01-22-2011, 02:36 PM
  4. Replies: 0
    Last Post: 02-28-2009, 11:16 AM
  5. Same values in an array
    By hawaiifiver in forum New To Java
    Replies: 3
    Last Post: 02-24-2009, 08:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •