Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demonstration of Non-Empty immutable list
jshell> List immutableList = List.of("Smart","Techie");
immutableList ==> [Smart, Techie]
jshell> //add an item to the list
jshell> immutableList.add("Smart_1");
| Warning:
| unchecked call to add(E) as a member of the raw type java.util.List
| immutableList.add("Smart_1");
| ^--------------------------^
| java.lang.UnsupportedOperationException thrown:
| at ImmutableCollections.uoe (
| at ImmutableCollections$AbstractImmutableList.add (
| at (#2:1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment