Well, often it's nice to know that an object is immutable. Particularly if there are any threading issues - you don't have to worry about the thread safety of an immutable object. Ever. So I think it's perfectly reasonable to want to create an immutable list of objects, and to want to do that as concisely as possible.
It's tempting to do
but this isn't really immutable. Better to do something like this:
Peter Fat wrote:This list will be used to create the keys for an HashMap, and these will always be the same. But since I'm beginning programming, I should ask: how is this done in the more professional way?
Java does not have a literal syntax for collections such as lists, maps etc. (this might be a feature that will be included in some future version of Java). Mike's answer is good if you really want an immutable list. I'd also make the member variable static; you do not need an instance of the list for each object that you create with the class. The usual convention for static final variables in Java is to have all-capital names: