# Thread: [508] Need help with an array list, will rep+

1. hey guys i need help with an array (think thats wht this is called) anyways

i declared this in player.java
Code:
``public int Items[] = { 0,1,2 };``
i need help knowing how to add/delete integers out of this list/array w.e.
so if i say del(p, 0); it will turn into.

Code:
``public int Items[] = { 1,2 };``
any help? :x

2. Well call on it you would do p.Items[index];

To add to it you would do p.Items[index] == 9549 or something.

now way i thing you want do it is like this...

public int[] Items = new int[28];
or
public int[] Items = {0,1,2,3,4,5,6,7 all the way to 28 or something};
and add to them same way as before and also their all set as 0 if use the frist one.

And to remove them you could set the index to be -1 or something

Btw to find out the index just take one away so be like this
0 1 2 3 4 Index

{49,98799,987899,78779,89779}
Hope this helps.

3. wow thanks ^-^ rep++

4. Originally Posted by Hoster
Well call on it you would do p.Items[index];

To add to it you would do p.Items[index] == 9549 or something.

now way i thing you want do it is like this...

or

and add to them same way as before and also their all set as 0 if use the frist one.

And to remove them you could set the index to be -1 or something

Btw to find out the index just take one away so be like this

Hope this helps.
umm, wtf are you smoking?

Anyways if you have a list like the one you posted
public int items[] = {0,1,2,3};
you wouldn't be able to remove and of the 4 integers from it, you can only set them to the null value of -1

5. well could i make it set the certain #, like set 0 to -1 and still have 1, 2 in there?

6. Originally Posted by Domanico
well could i make it set the certain #, like set 0 to -1 and still have 1, 2 in there?
Code:
``````                             //0, 1, 2, 3
public int Items[] = { 0,1,999,4 };``````
using

Code:
``Items[2] = 3;``
will make it

Code:
``public int Items[] = { 0,1,3,4 };``
using

Code:
``Items[3] = -1;``
will make it

Code:
``public int Items[] = { 0,1,3,-1 };``