How is Arrays.asList() different than the standard way of initialising List?
(a) Both are same
(b) Arrays.asList() throws compilation error
(c) Arrays.asList() returns a fixed length list and doesn’t allow to add or remove elements
(d) We cannot access the list returned using Arrays.asList()
(a) Both are same
(b) Arrays.asList() throws compilation error
(c) Arrays.asList() returns a fixed length list and doesn’t allow to add or remove elements
(d) We cannot access the list returned using Arrays.asList()
The correct answer is (c) Arrays.asList() returns a fixed length list and doesn’t allow to add or remove elements
Easiest explanation: List returned by Arrays.asList() is a fixed length list which doesn’t allow us to add or remove element from it.add() and remove() method will throw UnSupportedOperationException if used.