Is there a way to define a type for a Collection?
If I have the following:
private Map<String, A> myMap;
then is there a way to define Map<String, A> as a new type MapOfTypeA, for example, so that I can define myMap as
private MapOfTypeA myMap;
as an extension of this, is there a way to have the following:
myMap = new MapOfTypeA();
actually be
myMap = new HashMap<String, A>();
I’m not sure of what to call what I am asking, but I think I have explained it. In C or C++ it would be a typedef, I think.
You could define MapOfTypeA as
But not sure what the purpose is. If your concern is verbosity, then Java 7 has introduced the diamond operator that you can use to declare your map like this:
instead of