List<Integer> numList = Arrays.asList(nums);
Array.asList()
return an array but wrap in List interface. So The list is still backed by the array and the arrays are the fixed size, you cannot add/delete elements from array. That why next line will throw exception UnsupportedOperationException
.
For more detail, java ArrayList
is still an array behind, but it has some helper method, for you to delete/add elements (you can wiki for phrase resizeable array
for more detail.
Secondly, SortedSet
is an interface. Interface like abstract class, can have reference to a class that implements/extends its, but it's not concrete class, so you cannot create object on those (interface nor abstract class).
And I see, both two questions you ask, maybe relate to polymorphism
in OOP, I recommend you wiki this phrase too.
Hope this help :)