When using the mybatis plus plug-in to interact the springboot project with the MySQL database, the list & lt; object> The type is directly put into the database through the user-defined converter, and the display is successful. However, in the add operation of the list, the unsupported operationexception is returned,
The ArrayList in the source code of arrays.aslist in the figure above is not our commonly used ArrayList. Our commonly used ArrayList is java.util.arraylist, while the new in the figure above is java.util.arrays.arraylist, which is an internal class under the arrays class. Its class declaration is as follows:
It can be seen that both it and java.util.arraylist inherit from the abstractlist abstract class, but it does not implement the add method and remove method. When we call the add method, it actually calls the add method of the parent abstractlist.
Add calls the add method with two parameters.
Then you will see throw new unsupported operationexception();
To solve the above problem, just put the list into Java. Util. ArrayList, list & lt; Integer> Lists = new ArrayList (list), and then you can use lists to do various operations. Programmers should be careful and look at the source code
- Java container — unsupported operation exception
- [Solved] Arrays.asList() Error: java.lang.UnsupportedOperationException
- How to Solve Java Error: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
- Convert Object to List>, avoiding Unchecked cast: ‘java.lang.Object’ to ‘java.util.List
- Postman passing Josn field error: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_STRING token
- How to Solve Error: Scanner class java. Util. NoSuchElementException exception
- [Solved] Exception in thread “main” java.util.ConcurrentModificationException
- [leetcode] 140. Word break II word split II
- How to Solve Ajax Error 500 (Internal Server Error)
- The problem of user.home environment variable in Java