Home » Tag Archives: Google Guava (page 3)

Tag Archives: Google Guava

Selecting your Collections library

java-logo

Is this really something you should bother? Is there something fundamentally wrong with java.util.ArrayList and java.util.HashMap? For most of the source code out there the answer is – no; those implementations are perfectly OK. But as always, the devil is in the details. And there exist situations when either the feature set built into the Collections API is not sufficient ...

Read More »

Collection creation and Immutability with Google Guava

java-interview-questions-answers

So, thought I’d take a look at some of the collection creation patterns Guava offers, and also some of the Immutable collection types it offers. If you’ve not seen my previous posts, you may want to start here: Guava part 1 – MultiMaps Guava part 2 – BiMaps Guava part 3 – MultiSets   create methods All of Guava’s collection ...

Read More »

Google Guava Multisets

java-interview-questions-answers

Continuing this tour of Guava we get to the Multiset. I probably don’t use this as much as Multimaps or Bimaps, but it certainly does have it’s uses. So what’s a Multiset then? Well as you might be able to guess it’s a set that can hold multiple instances of the same object.         Isn’t that just ...

Read More »

ANTLR – Semantic Predicates

antlr-logo

Parsing simple grammar with antlr is simple. All you have to do is to use regular expressions to describe your language and let antlr generate lexer and parser. Parsing big or complicated languages occasionally require more, because describing them in regular expressions only can be hard or even impossible. Semantic predicates are java (or C++, or JavaScript, or …) conditions ...

Read More »

Functional Java collections

java-logo

There is a lot of functional hype these days so I would give a short overview on what is out there at least when it comes to collections in Java. Personally I like standard collections API but i some cases can be awkward and add additional verboseness. This should not be a problem in latter version of Java 8+. There ...

Read More »

Google Guava BiMaps

java-interview-questions-answers

Next up on my tour of Guava, is the BiMap, another useful collection type. It’s pretty simple really, a BiMap is simply a two way map. Inverting a Map A normal java map is a set of keys and values, and you can look up values by key, very useful, eg lets say I wanted to create a (very rudimentary) ...

Read More »

Guava Splitter vs StringUtils

java-logo

So I recently wrote a post about good old reliable Apache Commons StringUtils, which provoked a couple of comments, one of which was that Google Guava provides better mechanisms for joining and splitting Strings. I have to admit, this is a corner of Guava I’ve yet to explore. So thought I ought to take a closer look, and compare with ...

Read More »

Google Guava BloomFilter

java-logo

When the Guava project released version 11.0, one of the new additions was the BloomFilter class. A BloomFilter is a unique data-structure used to indicate if an element is contained in a set. What makes a BloomFilter interesting is it will indicate if an element is absolutely not contained, or may be contained in a set. This property of never ...

Read More »

Google Guava EventBus and Java 7 WatchService for Event Programming

java-interview-questions-answers

This post is going to cover using the Guava EventBus to publish changes to a directory or sub-directories detected by the Java 7 WatchService. The Guava EventBus is a great way to add publish/subscribe communication to an application. The WatchService, new in the Java 7 java.nio.file package, is used to monitor a directory for changes. Since the EventBus and WatchService ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.