Java: static declaration of collection
Posted by: pureessence on: December 17, 2008
I don’t know if this is a new feature in Java 5 that I did not know before or I just did not know this is possible in Java. But I learned today that you can do static declaration of collection types as below:
public static List supportedCopyPropertyTypes = new ArrayList() {
private static final long serialVersionUID = 660145948432567403L;
{
add("String");
add("BigDecimal");
add("int");
}
};
Advertisement
Like this:
Be the first to like this post.
December 7, 2010 at 1:58 pm
always nice to find useful code samples online!
Thanks for this one.