Why am i getting 'unsupportedoperationexception in java'?
Example:
List list = Arrays.asList(1, 2, 3);
list.add(4);
Solution:
This error occurs when an unsupported operation is invoked. In this case, `Arrays.asList()` returns a fixed-size list. Use a mutable list like `ArrayList` for adding/removing elements.
List list = new ArrayList<>(Arrays.asList(1, 2, 3));
list.add(4);