I am unable to add an element to a list? UnsupportedOperationException

前端 未结 3 1941
粉色の甜心
粉色の甜心 2020-12-17 14:39

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.UnsupportedOperationEx         


        
3条回答
  •  独厮守ぢ
    2020-12-17 15:11

    This exception is very familiar with accessing objects that will not permit the access according to java language rules like accessing immutable objects, for that reason instantiate it in the following way instead:

    AdventureLobbies.players = new ArrayList(Arrays.
    asList(rs.getString("players").toLowerCase().split(","))); // Perfectly done
    

提交回复
热议问题