Results 1 to 2 of 2
  1. #1
    irnie1994 is offline Member
    Join Date
    Aug 2011
    Posts
    28
    Rep Power
    0

    Default Swap array value

    Swap array value-ok.png

    what was missing for my program??

    --->
    int temp = myArray[i];
    myArray[i] = myArray[i+1];
    myArray[i+1] = temp;

    the output 10,9,8,7 for up and down 6,3,2,1
    Last edited by irnie1994; 11-10-2011 at 04:59 PM.

  2. #2
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Swap array value

    You have 2 options:
    1) Work on 2 arrays.
    2) Work on 1 2d array.

    Try now and post your code here if you get any problems.

Similar Threads

  1. how can i loop my array swap
    By belfast09 in forum New To Java
    Replies: 3
    Last Post: 06-15-2011, 04:35 AM
  2. Multidimensional array - swap
    By BeginnerNoob in forum New To Java
    Replies: 13
    Last Post: 03-30-2011, 03:02 PM
  3. swap method
    By leavearth in forum New To Java
    Replies: 1
    Last Post: 04-24-2010, 06:59 PM
  4. Swap characters in a string.
    By Sdannenberg3 in forum New To Java
    Replies: 4
    Last Post: 03-04-2010, 08:49 PM
  5. how to swap 2 numbers
    By mary in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 05:32 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
  •