Вопрос

List<String> s = getConfig().getStringList("clanowner");
if (!(s.isEmpty())) {

    for (String str : s) {
        String[] words = str.split(":");
        menu.clanowner.put(words[0], words[1]);
    }
}

So, I am getting a java.lang.indexoutofboundsexception, but I have no idea why this is happening. Will somebody please help me?

Это было полезно?

Решение

My hunch is that

String[] words = str.split(":");

is probably not returning an array of length 2. Changing the last line of the for statement to

if(words != null && words.length > 1) {
    menu.clanowner.put(words[0], words[1]);
}

should eliminate the IndexOutOfBoundsException.

As a debugging practice, it also helps to know exactly what it going in there, so make sure that

List<String> s = getConfig().getStringList("clanowner");

truly is giving you output that should produce arrays of length 2 or more either by debugging or manually inserting values that should work, or both.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top