On executing this code, I am getting a java.lang.UnsupportedOperationException on line 81. I know posting entire code is against bet practices, but I thought it would be qu
Arrays.asList(tempArr)
returns a fixed-size list backed by that array. You cannot remove elements from (or add elements to) it.
Note that the list returned by Arrays.asList remains backed by that array, so that when you update elements in the list, it will change them in the array as well.
If you need a modifiable copy, use
new ArrayList(Arrays.asList(tempArr))