标签:混合 tree element end 有意思 maps guava multiset java
//有意思的builder写法
ImmutableSet<Color> GOOGLE_COLORS =
ImmutableSet.<Color>builder()
.addAll(WEBSAFE_COLORS)
.add(new Color(0, 191, 255))
.build();
Multiset<Integer> set = HashMultiset.<Integer>create();
HashMultimap<Integer, Integer> map = HashMultimap.create();
// 使用LinkedHashMaps替代HashMaps
Table<String, Character, Integer> table = Tables.newCustomTable(
Maps.<String, Map<Character, Integer>>newLinkedHashMap(),
new Supplier<Map<Character, Integer>> () {
public Map<Character, Integer> get() {
return Maps.newLinkedHashMap();
}
});
List<String> theseElements = Lists.newArrayList("alpha", "beta", "gamma");
Set<Type> approx100Set = Sets.newHashSetWithExpectedSize(100);
Multiset<String> multiset = HashMultiset.create();
List<String> readLines = Files.readLines(file,Charsets.UTF_8);
保证调用Closer.close方法时,所有注册的Closeable对象都正确的关闭
Closer closer = Closer.create();
closer.register(reader);
closer.register(writer);
catch (Throwable t) {
throw closer.rethrow(t);
} finally {
closer.close();
}
标签:混合 tree element end 有意思 maps guava multiset java
原文地址:https://www.cnblogs.com/lknny/p/12218752.html