If you cannot wait for Java 1.7, use usual trick with anonymous classes and static initializer block:
Java 1.7:
List<String> list = ["item"];
Java 1.2:
List<String> list = new AList<String>() {{ items=["item"]; }};
where: public class AList<T> implements List<T> {
protected T[] items;
// Implementation
}
Set<String> set = {"item"};
Set<String> set = new ASet<String>() {{ items={"item"}; }};
Map<String, Integer> map = {"key" : 1};
Map<String, Integer> map = new AMap<String, Integer>() {{ keys=["key"]; values=[1]; }};
I can post detailed explanation and examples of this technique, which I love to use, in my blog, if somebody will be interested. (English is foreign language to me).It is much better than to use full blown implementation and bunch of setters just to pass around one or two elements.
I often use this technique to pass optional data to/from methods or to program in declarative style in java.