Skip to content

Instantly share code, notes, and snippets.

@EduardoSaverin
Last active November 3, 2021 13:25
Show Gist options
  • Save EduardoSaverin/46754fa077cd9e4d8159452a105c68ef to your computer and use it in GitHub Desktop.
Save EduardoSaverin/46754fa077cd9e4d8159452a105c68ef to your computer and use it in GitHub Desktop.
java9list
List<String> list=List.of("apple","bat");
List<String> list=List.of("apple",null); // It doesn't allow null values - NullPointerException will be thrown if added.
Set<String> set1= Set.of("apple","bat");
Set<String> set2= Set.of();
Map<Integer,String> emptyMap = Map.of();
Map<Integer,String> map = Map.of(1, "Apple", 2, "Bat", 3, "Cat");
Map<Integer,String> mapEntry = Map.ofEntries(
Map.entry(1,"Apple"),
Map.entry(2,"Bat"),
Map.entry(3,"Cat"));
List<String> list=List.of("apple","bat");
List<String> list=List.of("apple",null); // It doesn't allow null values - NullPointerException will be thrown if added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment