转自:https://www.it1352.com/968919.html
This one list object is biting me in the butt..
Any time I try to add an element to it, it produces this:
Caused by: java.lang.UnsupportedOperationException at java.util.AbstractList.add(AbstractList.java:148) at java.util.AbstractList.add(AbstractList.java:108)
The line producing the error is insignificant, but here it is anyways:
AdventureLobbies.players.add(args[0].toLowerCase());
Should I not be accessing it statically?
Actual declaration of variable:
AdventureLobbies.players = Arrays.asList(rs.getString("players").toLowerCase().split(","));
Any ideas? Can't find anything on Google that's worthwhile.
解决方案
Arrays.asList() will give you back an unmodifiable list, and that is why your add is failing. Try creating the list with:
AdventureLobbies.players = new ArrayList(Arrays.asList(rs.getString("players").toLowerCase().split(",")));
这一个列表对象正在咬我... ...
每当我尝试添加一个元素时,它就会产生这个:
由以下原因引起:java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:148)
at java.util.AbstractList.add(AbstractList.java:108)
产生错误的行是无关紧要,但无论如何:
AdventureLobbies.players.add(args [0] .toLowerCase());
我是否应该静态访问它?
< p>变量的实际声明:
AdventureLobbies.players = Arrays.asList(rs.getString("players")。toLowerCase()。split (","));
任何想法?在谷歌上找不到任何值得的东西。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步