Results 1 to 4 of 4
  1. #1
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default how can i loop my array swap

    im still working on my assignment showed in my previous post and wondering when i am removing the array elements (student grade and marks) i can only seem to remove 1 and move on element down into its can i use a loop to bring the others down so there are no spaces between elements and when an element is added it becomes the last any help would be much appreciated

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,387
    Rep Power
    25

    Default

    i can only seem to remove 1 and move on element down into its can i use a loop
    when an element is added it becomes the last any help
    Can you reword this. I can't make sense of what you are writing.

    It would help if you wrote a small simple program that demonstrates your problem.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    You cannot delete an element from an array. Once an array has been created, its length is set and can never be changed. All you can do is overwrite the value in the element. So if you had {1,2,3,4,5} and wanted to delete 2 then you would need a loop to copy each element after 2 down one slot. Note: as stated above you cannot delete the 5 in the last element so the array would be {1,3,4,5,5}. The only choice you have to handle this is to have a variable to hold how many values are present in the array. On "deleting" the 2 you would then decrement the variable.

  4. #4
    belfast09 is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Default

    listen lads i was in a car accident 2 years ago and broke my neck at c4 i use an integra mouse (look it up) ive no use of my hands and use an on screen keyboard to type i also am very slow at typing i missed the classes i know the gui part and breezed the 2nd assignment im close to completion i only need a bit of help for the removing adding and modifying i know its frustrating but the teacher doesn't have the time

Similar Threads

  1. Multidimensional array - swap
    By BeginnerNoob in forum New To Java
    Replies: 13
    Last Post: 03-30-2011, 03:02 PM
  2. Array or for loop? or both?
    By kedecr in forum New To Java
    Replies: 4
    Last Post: 03-09-2011, 01:24 PM
  3. Loop through Array in JSP
    By Robert_85 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 04-25-2010, 09:00 PM
  4. swap method
    By leavearth in forum New To Java
    Replies: 1
    Last Post: 04-24-2010, 06:59 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
  •