Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demonstration of Immutable empty list
jshell> List immutableList = List.of();
immutableList ==> []
//Add an item to the list
jshell> immutableList.add("Smart");
| Warning:
| unchecked call to add(E) as a member of the raw type java.util.List
| immutableList.add("Smart");
| ^------------------------^
| java.lang.UnsupportedOperationException thrown:
| at ImmutableCollections.uoe (ImmutableCollections.java:70)
| at ImmutableCollections$AbstractImmutableList.add (ImmutableCollections.java:76)
| at (#2:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.