Results 1 to 5 of 5
  1. #1
    Cruncher is offline Member
    Join Date
    Mar 2010
    Posts
    88
    Rep Power
    0

    Default Removing indexes from an array.

    Okay, i wasn't sure if this should go in "new to java" or "advanced java" as i'm not sure how complicated the code will be.

    Basically say i have an array of type "TetrisBox" and i want to get rid of, say 10 of them(see where this is going? lol). the problem is that these arrays aren't in order, so it leaves index holes and i'm not to sure what to do about it.

    I was thinking of writing a method to do it, but i'm not even sure if objects are passes by reference or by value, and it would seem like a complicated method.

    Is there an easy way to do this in Java??

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Don't use arrays, they're kind of stupid when it comes to rearranging their elements. Use ArrayLists instead. btw, Java use pass by value; always.

    kind regards,

    Jos

  3. #3
    Cruncher is offline Member
    Join Date
    Mar 2010
    Posts
    88
    Rep Power
    0

    Default

    How do i use ArrayList with a non-primitive type?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cruncher View Post
    How do i use ArrayList with a non-primitive type?
    ArrayLists can only be used with non-primitve types.

    kind regards,

    Jos

  5. #5
    Cruncher is offline Member
    Join Date
    Mar 2010
    Posts
    88
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2009, 05:58 PM
  2. array indexes
    By Kaito in forum New To Java
    Replies: 5
    Last Post: 10-30-2009, 03:14 AM
  3. Removing Indexes
    By gilbertsavier in forum JDBC
    Replies: 0
    Last Post: 07-17-2009, 07:23 AM
  4. Creating Indexes
    By gilbertsavier in forum JDBC
    Replies: 0
    Last Post: 07-17-2009, 07:23 AM
  5. removing 0 from the begining of the array
    By Hayzam in forum New To Java
    Replies: 7
    Last Post: 08-21-2008, 10:02 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
  •