This is a small demo project I put together to introduce Google Guava here at Betfair.

I recently gave a short at work about some of the cool features available in Google Guava , and thought it would be useful to publish online in case the topic interests anyone else. The demo code doesn't do anything fancy, but should highlight some of the useful stuff that you would've previously had to do manually.

Most of these topics don't cover anything ground-breaking, but they do provide some incredibly useful utilities to speed up development and reduce the amount of repetitive code you have to write. Particularly interesting are the additional collection types provided by Guava, as well as the static classes like Lists, Maps, Sets, Iterables, etc. There's been some recent activity on the Guava Wiki which is excellent... unfortunately this wasn't available when I was putting together this talk. I'd recommend you check out the wiki now for more up-to-date explanations directly from the source.

Other classes that are definitely worth investigating further - particularly if you've not had much exposure to functional programming - are Function / Functions and Predicate / Predicates. Java is very far behind in terms of introducing functional programming constructs (due only in Java 8), but these classes might help you solve problems using a more functional approach, which will make you very eager for closures to be introduced as a first class feature of the language!

My talk focused on these main sections:

  • Basics
  • Strings
  • Collections
  • Functional Programming
  • Concurrency

Each section has some code to demonstrate some of the features that are likely to be used more frequently than others (of course, you might find other classes more useful). Please feel free to add your changes if you think anything's missing... or just fork the code to modify and use for your own demo.

The source for these examples can be found here:


20 December 2011