Adding lists from cofing to an array list.

Discussion in 'Plugin Development' started by bkleinman1, Oct 19, 2013.

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

    bkleinman1

    How would i add a list i have got in a config into an array list, i have tried this:
    Code:java
    1. arenas.add(getConfig().getList("arenas"));

    but i was getting an error, im guessing .add only allows adding of one string, so i would have to go through all of the strings in the config list adding them individually, but i'm not sure how to do that. Any help would be greatly appreciated.
     
  2. Offline

    1Rogue

    Code:java
    1. arenas.addAll(getConfig().getList("arenas"));
     
  3. Offline

    bkleinman1

    1Rogue im getting an error on 'addAll'
     
  4. Offline

    1Rogue


    What is the error? It should accept any collection argument
     
  5. Offline

    bkleinman1

    1Rogue The method addAll(Collection<? extends String>) in the type ArrayList<String> is not applicable for the arguments (List<capture#1-of ?>)
     
  6. Offline

    1Rogue

    I see, try:

    Code:java
    1. List<String> data = getConfig().getList("arenas");
    2. arenas.addAll(data);
     
  7. Offline

    bkleinman1

    1Rogue now im getting this error: Type mismatch: cannot convert from List<capture#1-of ?> to List<String>
     
  8. Offline

    1Rogue

    use .getStringList() iirc.
     
  9. Offline

    bkleinman1

Thread Status:
Not open for further replies.

Share This Page