posted 13 years ago
Hi Everybody,
I have been going through Joshua Bloch's "Effective Java". In the second chapter I found the following:
Using Static Factory methods to reduce the verbosity of creating parameterized instances.
Instead of,
the suggestion is a following Static Factory Method:
Therefore, the change would be
In the above example, can anyone tell me how this is done ?
Because until the assignment to "testMap", the Map object has no way of knowing what type of key-value instances are to be assigned to it.
This is different from a generic class.
Here, V can be considered a placeholder and we know it is replaced with "Integer".
But I am not seeing anything of that sort with the static factory method.
Can anybody explain how ?
Thanks in advance :-)