I read this post: Difference between Arrays.asList(array) vs new ArrayList<Integer>(Arrays.asList(ia)) in java
and I have a question about it. I look at the line:
List<Integer> list2 = Arrays.asList(ia)
and still there is a line saying:
Of course, some List operations aren't allowed on the wrapper, like adding or removing elements from the list, you can only read or overwrite the elements.
If list2 has a reference of List Interface, I expect it to implement ALL methods included in List interface in Java. https://docs.oracle.com/javase/7/docs/api/java/util/List.html.
add(int index, E element)
and
remove(int index)
show in List interface, so how is it possible that they are not implemented in list2?
I would have expected that list2 is a List; and thus I could call all methods belonging to the List interface?! So why are there exceptions thrown when calling add() or remove()?