I have collection of maps.
Collection<Map<String,Object>> xyz = (Collection<Map<String,Object>>) someMethod();
xyz.add(new HashMap<>());
If I try to add another map to this collection it gives me run time exception as
UnsupportedOperation.
What can be done?
Most likely because someMethod() returns a collection which you can’t insert into. If it is a “Rread only” collection, then it will throw UnsupportedOperation on all insert/add calls.