Ordinate list from config?

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

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


    (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 :'(
    HashSet<String> hs = new HashSet<String>();
                for (String str : config.getConfigurationSection(path).getKeys(false))
                return hs;
    doesnt work..
  2. Offline


    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



    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


    Thanks tomorrow ill check if works

    works, heres the code
    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