Created
February 15, 2017 17:17
-
-
Save 2013techsmarts/6ea49440484bf439b2032b75528f7ddc to your computer and use it in GitHub Desktop.
Demonstration of Immutable empty list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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