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

Results 1 to 6 of 6
  1. #1 [508] Need help with an array list, will rep+ 
    ★☆♥♣♥☆★

    EndlessZombies's Avatar
    Join Date
    Aug 2008
    Age
    29
    Posts
    440
    Thanks given
    30
    Thanks received
    4
    Rep Power
    125
    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

    "Snapback with my city on it, text back with yo titties on it, levi's with yo kitty on it"


    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Jul 2008
    Posts
    539
    Thanks given
    4
    Thanks received
    8
    Rep Power
    89
    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.
    Reply With Quote  
     

  3. #3  
    ★☆♥♣♥☆★

    EndlessZombies's Avatar
    Join Date
    Aug 2008
    Age
    29
    Posts
    440
    Thanks given
    30
    Thanks received
    4
    Rep Power
    125
    wow thanks ^-^ rep++

    "Snapback with my city on it, text back with yo titties on it, levi's with yo kitty on it"


    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    Quote Originally Posted by Hoster View Post
    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
    Reply With Quote  
     

  5. #5  
    ★☆♥♣♥☆★

    EndlessZombies's Avatar
    Join Date
    Aug 2008
    Age
    29
    Posts
    440
    Thanks given
    30
    Thanks received
    4
    Rep Power
    125
    well could i make it set the certain #, like set 0 to -1 and still have 1, 2 in there?

    "Snapback with my city on it, text back with yo titties on it, levi's with yo kitty on it"


    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Aug 2008
    Posts
    1,171
    Thanks given
    21
    Thanks received
    44
    Rep Power
    0
    Quote Originally Posted by Domanico View Post
    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 };
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •