-
-
Save knoxknox/fd82e4d45d9668a8059a9261d4424b70 to your computer and use it in GitHub Desktop.
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
// create a mutable set | |
Set<String> set = Sets.newHashSet("Jay", "Betsy"); | |
// create an immutable set | |
Set<String> set = ImmutableSet.of("Jay", "Betsy", "Jenny"); | |
// create a mutable list | |
List<String> list = Lists.newArrayList("Jay", "Betsy"); | |
// create an immutable list | |
List<String> list = ImmutableList.of("Jay", "Betsy", "Jenny"); | |
// create a mutable map | |
Map<Integer, String> map = Maps.newHashMap(ImmutableMap.of(1, "Jay", 2, "Betsy")); | |
// create an immutable map | |
Map<Integer, String> map = ImmutableMap.of(1, "Jay", 2, "Betsy", 3, "Jenny", 4, "Joe"); | |
// create an immutable map (builder) | |
Map<Integer, String> map = ImmutableMap.<Integer, String> builder().put(1, "Jay").put(2, "Betsy").build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment