4 ms·
I recently started a Java job after having avoided it in favour of better languages for some time. I've found the Google Guava library makes Java programming a
by GlennS 14y ago
I recently started a Java job after having avoided it in favour of better languages for some time. I've found the Google Guava library makes Java programming a lot more bearable: https://code.google.com/p/guava-libraries/ https://code.google.com/p/guava-libraries/
Thinks that will make your life easier
* Collections2.filter() -> this is just filter()
* Collections2.transform() -> this is map()
* ImmutableMap.of() -> for when you need to create a quick lookup
You still have to make an anonymous inner class every time you want to pass a function as an argument though.
- ollysb 14y agoYeah, I actually wrote some similar functions for java when I first started experimenting with ruby on the side. I agree it's a big improvement on for loops but there's still a lot of line noise; the anonymous class(as you mention) and having to passing the collection into a static method which is never great. Importing Collections2 statically does make it a bit more pleasant though.