There's a nice ```BiMap``` class in the Google collections library that does exactly this :)