Results 1 to 3 of 3
  1. #1
    FiniteRed is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default J2ME Dynamic arrays

    Hi

    I need to use an array of objects in my J2Me application that will need to both grow and shrink depending on the number of objects contained within. I have so far re-created the entire array each time a new object is to be added or removed with either one more or one less element - this works but is horrible in terms of eficiency and (i suspect) memory usage.

    Is there another way? (I'm stuck using JDK1.5)

    Cheers for any advice given!

    FR

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,305
    Rep Power
    20

    Default

    That's about the same way the Java ME core classes (as also Collection classes like ArrayList) do it.

    For improving the efficiency, go through the source of (Java SE) java.util.ArrayList -- it doesn't recreate the array on every add/remove.

    db

  3. #3
    FiniteRed is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 01:40 AM
  2. 2d dynamic arrays
    By seeder in forum Advanced Java
    Replies: 1
    Last Post: 03-15-2010, 10:03 AM
  3. dynamic two dimensional arrays?
    By dinosoep in forum New To Java
    Replies: 4
    Last Post: 12-05-2009, 06:12 PM
  4. Replies: 0
    Last Post: 04-22-2009, 01:30 PM
  5. How to create Dynamic application using J2ME?
    By sharmaj2me in forum CLDC and MIDP
    Replies: 1
    Last Post: 01-31-2009, 03:19 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
  •