Ordinate list from config?

Discussion in 'Plugin Development' started by 4thegame3, Sep 9, 2014.

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

    4thegame3

    (Maybe suggest me a better title)

    I need to get an ordinate list of sections from config but i really dont know how to do that :'(
    Code:
    HashSet<String> hs = new HashSet<String>();
                for (String str : config.getConfigurationSection(path).getKeys(false))
                    hs.add(str);
                return hs;
    doesnt work..
     
  2. Offline

    WinX64

    If you want insertion ordering, use another implementation of Set as HashSet doesn't provide ordering of elements.
    A LinkedHashSet or even a list is what you need.
     
    4thegame3 likes this.
  3. Offline

    mythbusterma

    4thegame3

    The Java "Set" specification specifically states that the contents are not guaranteed to be ordered, and should not be relied upon to be ordered. Instead, use a List, which is guaranteed to be ordered (your best bet would probably be an ArrayList).
     
  4. Offline

    4thegame3

    @mythbusterma
    @WinX64
    Thanks tomorrow ill check if works

    works, heres the code
    Code:java
    1. List<String> test = new ArrayList<String>();
    2. for (String str : config.getConfigurationSection(Path).getKeys(false)){
    3. test.add(str);
    4. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page