geeky

Java: static declaration of collection

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");
		}
	};

One thought on “Java: static declaration of collection

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s