List<Integer> numbers = Lists.newArrayList(1, 2, 3, 4, 5); List<Integer> evenNumbers = Lists.newArrayList(Collections2.filter(numbers, n -> n % 2 == 0)); ImmutableList<String> colors = ImmutableList.of("red", "green", "blue"); ImmutableList<String> modifiedColors = ImmutableList.<String>builder() .addAll(colors) .add("yellow") .build(); ConcurrentMap<String, Integer> countMap = new ConcurrentHashMap<>(); countMap.putIfAbsent("apple", 0); countMap.computeIfPresent("apple", (k, v) -> v + 1); String repeatedString = Strings.repeat("abc", 3); LoadingCache<String, Object> cache = CacheBuilder.newBuilder() .maximumSize(100) .expireAfterAccess(10, TimeUnit.MINUTES) .build(new CacheLoader<String, Object>() { @Override public Object load(String key) throws Exception { return loadDataFromDatabase(key); } });


上一篇:
下一篇:
切换中文