Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Filling Arrays

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Filling Arrays

    Hello All,

    int[] alphaIntArray = { 9, 3, 7, 2};
    int[] betaIntArray = { 8, 1, 6, 5,};

    Can you please advise coding that would fill alphaIntArray with the elements of betaIntArray.

    kind regards,


    av8


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Filling Arrays

    If the two arrays are of the same size, you can Write a loop to copy the elements of one to the other.
    for(int i=0; etc
    alphaIntArry[i] = betaIntArray[i]; copy contents of b to a

  3. #3
    Member
    Join Date
    Jun 2011
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Filling Arrays

    Thanks alot, I appreciate your help, will try out now.

    rgds av8.

  4. #4
    Junior Member Mrc0d3r's Avatar
    Join Date
    Jun 2011
    Location
    TCP/IP Layer 3
    Posts
    25
    My Mood
    Bored
    Thanks
    0
    Thanked 6 Times in 5 Posts

    Default Re: Filling Arrays

    System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) ?

Similar Threads

  1. Arrays
    By av8 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 25th, 2011, 01:21 PM
  2. filling an array with strings
    By exose in forum Collections and Generics
    Replies: 3
    Last Post: February 18th, 2011, 09:44 AM
  3. [SOLVED] Filling in alternating colors of a "BullsEye"
    By forte in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 22nd, 2010, 06:05 PM
  4. Chessboard filling issue
    By olemagro in forum AWT / Java Swing
    Replies: 7
    Last Post: January 23rd, 2010, 07:07 PM
  5. Filling an Array?
    By Bascotie in forum Collections and Generics
    Replies: 5
    Last Post: October 14th, 2009, 06:27 PM