on 01-20-2017 1:15 PM
I have one item type, which has list of another items. I want to update the list of items in that item type, but getting the above error.
E.g
I have College Item Type -- which have List of Student Item Types.
While updating the College item type, i want to add new Student type to the existed list of Student types. But facing java.lang.UnsupportedOperationException.
college.getStudents().add(newStudent); -- This line giving error.
Any help will be appreciated. Thanks
Hi,
The list you are trying to modify is unmodifiablelist , So you cannot modify the content of list. But you can do like below,
List list=new ArrayList(college.getStudents());
list.add(element);//add operation
list.remove(elment)//remove operation
college.setStudents(list);
modelService.save(college)
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.