@Test public void testCollectionInstance() { Maps.newLinkedHashMap(); Lists.newArrayList(); Sets.newHashSet(); ObjectArrays.newArray(Integer.class, 10); }
@Test public void show() { List<User> personList = Lists.newLinkedList(); Set<User> personSet = Sets.newHashSet(); Map<String, User> personMap = Maps.newHashMap(); Integer[] intArrays = ObjectArrays.newArray(Integer.class, 10); // -------------------- Set<String> set = Sets.newHashSet("one", "two", "three"); List<String> list = Lists.newArrayList("one", "two", "three"); Map<String, String> map = ImmutableMap.of("ON", "TRUE", "OFF", "FALSE"); // 2,简化集合的初始化 List<User> personList2 = Lists.newArrayList(new User("zhuc-1", 20), new User("zhuc-2", 25)); Set<User> personSet2 = Sets.newHashSet(new User("zhuc-1", 20), new User("zhuc-2", 25)); Map<String, User> personMap2 = ImmutableMap.of("hello", new User("zhuc-1", 20), "f**k", new User("zhuc-2", 25)); }