ArrayList.....

Discussion in 'Plugin Development' started by ChrisStarr32, May 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ChrisStarr32

    I am confused on how I should do this.

    This is what I am trying to do:
    Code:java
    1. public void Add(Player p, ArrayList array)
    2. {
    3. array.add(p.getUniqueId());
    4. }

    But when I do this I get:
    Code:
    ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized
    Code:java
    1. public void queuelist()
    2. {
    3. //do more stuff
    4. Add(playerOne, queuelist);
    5. }


    Thank You
    Chris
     
  2. Offline

    reider45

    I believe you need to add a parameter to the ArrayList

    Code:java
    1. public void Add(Player p, ArrayList array)
    2. {
    3. array.add(p.getUniqueId());
    4. }
    5.  
    6. // Should be
    7.  
    8. public void Add(Player p, ArrayList<String> array)
    9. {
    10. array.add(p.getUniqueId());
    11. }


    Let's say your queueList was

    Code:java
    1. List<String> queueList = new ArrayList<String>();
    2.  
    3. // You'd use the <String> like show in the example above.
    4.  
    5. // If your queuelist was like
    6.  
    7. List<Integer> queueList = new ArrayList<Integer>();


    Then your code would be
    Code:java
    1. public void Add(Player p, ArrayList<Integer> array)
    2. {
    3. array.add(p.getUniqueId());
    4. }


    Basically... you need to say what the array's storing :)
     
  3. Offline

    Not2EXceL

  4. Offline

    teej107

    The ArrayList you are passing in the parameters doesn't have a type. Something like this would work.
    Code:java
    1. public void Add(Player p, ArrayList<YourObjectTypeHere> array)
    2. {
    3. array.add(p.getUniqueId());
    4. }
     
  5. Offline

    ChrisStarr32

Thread Status:
Not open for further replies.

Share This Page