java.lang.UnsupportedOperationException while adding element to List created from Arrays.asList()
The arraylist which is created using below line of code is immutable. The reason behind is the list still backed/aided by the array and we all know pretty well that the size of the array cannot be changed. The Arrays.asList returns the arraylist which is the inner class with the name as arraylist. This list does not have methods that performs any modification to the arraylist add, remove etc. It is an inner class which extends abstract class AbstractList but not…