cmdolcet
asked on
How to determine if an arraylist item has been populated
I need to figure out where in my arraylist i am currently to populate it with an additional item.
I have an arraylist of size 8. I fill my first item slot and then do something else. I need to be able to check that item slot see if it is filled and then populate the next item slot.
I know the arraylist has a count. But thats not what im looking for.
I have an arraylist of size 8. I fill my first item slot and then do something else. I need to be able to check that item slot see if it is filled and then populate the next item slot.
I know the arraylist has a count. But thats not what im looking for.
ASKER
i do understand and I have gone about creating an initial size in a constructor. However in saying that the arraylist will fill up each time a timer is fired.
For example:
first pass -
slot 0: data is populated in the slot
slot 1:
slot 2:
slot 3:
slot 4:
slot 5:
slot 6:
slot 7:
Once data is populated the arraylist is exited and is saved.
On the next entry pass 2.
second pass after the
slot 0: data from pass 1
slot 1: data is populated in the slot
slot 2:
slot 3:
slot 4:
slot 5:
slot 6:
slot 7:
once the second slot is filled it will exit the routine.
For example:
first pass -
slot 0: data is populated in the slot
slot 1:
slot 2:
slot 3:
slot 4:
slot 5:
slot 6:
slot 7:
Once data is populated the arraylist is exited and is saved.
On the next entry pass 2.
second pass after the
slot 0: data from pass 1
slot 1: data is populated in the slot
slot 2:
slot 3:
slot 4:
slot 5:
slot 6:
slot 7:
once the second slot is filled it will exit the routine.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Even with an initial capacity, the ArrayList does NOT have anything it! If you know how many items you are going to insert beforehand then you can set capacity and the Arraylist will not have to increase in size INTERNALLY to hold the items.
Does that make sense at all?