0

I wrote this code:

List<String> doneTiers = new ArrayList<>();
if (ps.getData("achievements.Done") != null) {
    doneTiers = Arrays.asList(ps.getData("achievements.Done").split("/./"));
}
Msg.debug(tier, tier.getName());
doneTiers.add(tier.getName());// dodany
ps.setData("achievements.Done", DataUTIL.format(doneTiers, "/./"));

and I have error in this line doneTiers.add(tier.GetName());

UnsupportedOperationException

1 Answer 1

3

Arrays.asList() creates a fixed-size list, so once created, you cannot add more elements to it. Since you already initialized doneTiers with new ArrayList<>(), you can use addAll like this:

doneTiers.addAll(Arrays.asList(ps.getData("achievements.Done").split("/./")))
Sign up to request clarification or add additional context in comments.

2 Comments

hmm ah ok but how to create List from splited string? like this? for(String str : ps.getData("achivemenets.Done").split("/./")){ doneTiers.add(str); } ?
You're welcome! Little hint: if you like the answer, hit the big tick mark to the left of it to mark it as "accepted".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.