The arraylist which is created using below line of code is immutable.

List<String> list= Arrays.asList("one","two","three");

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.

public static <T> List<T> asList​(T... a){
 return new Arraylist<T>(array)
}

It is an inner class which extends abstract class AbstractList but not override any remove() or add() methods so it is unfair to expect it to behave as arraylist. The implementation for AbstractList looks like this

public abstract class AbstractList<E> implements List<E> {

    public E remove(int location) {
        throw new UnsupportedOperationException();
    }

    public E set(int location, E object) {        
        throw new UnsupportedOperationException();
    }

    public E add(int location, E object) {        
        throw new UnsupportedOperationException();
    }
.
.
.
.

}

That is when we get java.lang.UnsupportedOperationException if we try to update the arraylist. This exception is a runtime exception is thrown to indicate that the requested operation is not supported.

Please see the code below:-

List<String> list= Arrays.asList("one","two","three");	
		System.out.println("Printing list:\t"+list);
		list.add("four");
		System.out.println(list);

Output:-

Printing list:	[one, two, three]
Exception in thread "main" java.lang.UnsupportedOperationException
	at java.util.AbstractList.add(Unknown Source)
	at java.util.AbstractList.add(Unknown Source)
	at com.thread.Immutable.main(Immutable.java:11)

The above issue can be fixed to create the arraylist using the below code:-

List<String> newList= new ArrayList<String>( Arrays.asList("one","two","three"));
		System.out.println(newList);
		newList.add("four");
		System.out.println("Printing new list:\t"+newList);

Output:-

[one, two, three]
Printing new list:	[one, two, three, four]

Explanation:-

In the above code we are directly instantiating the Arraylist which supports all the operations which facilitates all possible operations.

Hope this helps. Please drop your comments in the box

Thanks!!