Skip to content

Instantly share code, notes, and snippets.

@2013techsmarts
Last active February 22, 2017 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2013techsmarts/f83eaef3d16a2b14bd86ddc072d73517 to your computer and use it in GitHub Desktop.
Save 2013techsmarts/f83eaef3d16a2b14bd86ddc072d73517 to your computer and use it in GitHub Desktop.
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 (ImmutableCollections.java:70)
| at ImmutableCollections$AbstractImmutableList.add (ImmutableCollections.java:76)
| at (#2:1)
jshell>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment