Skip to content

Project Espresso4J – Java inline arrays, lists, and maps

Java 7’s recent release has sparked some interesting discussion, some excited by the new features, some disappointed that it’s too little too late… But this isn’t one of those internet rants about the future of Java; this is about using a language to its full extent!

Ok so native support for Collections Framework isn’t coming until Java 8 and that kinda sucks but what Java does have is decent support for Generic Programming! Really, it’s a rather undersold feature that doesn’t get pushed as often as it could be. Combine Java Generics with a little bit of creativity and this other nifty feature, static importing, and it’s possible to simulate, to create the illusion of inline collection types: sets, lists, maps, and even inline arrays.

This is exactly what Espresso4J does – it gives Java a shot of liveliness to boost its syntax. This lightweight package provides a useful API for constructing arrays, sets, lists, and maps in a much more concise manner than usually seen in Java code, without any loss of expressiveness. Now that’s some good coffee;)