hm.put("hash","test");// this should not allow here as Map i have declared as final. [
Final does not imply unmodifiable, unless the object is immutable. If you want an unmodifiable map have a look at the Collections class, or alternatively wrap the map in your own custom immutable class.
only that type of classes are final in nature.
if same way
in Abstract Class
Map hm = new HashMap();
in the above case it is implictily final
A final class is a class that cannot be subclassed. There's nothing to prevent you having a final class that is modifiable, it simply means that you can't inherit from it.
An immutable, or unmodifiable, class is a class where the state cannot be changed because there are no methods available to change the state. Assuming you've made all the member variables private then objects can only be changed via setter methods etc...and if you haven't provided any then it's immutable.
(String happens to be an example that is both final and immutable).
A final reference is a variable that, once initialised, cannot be changed. A reference being final is completely unrelated to whether the object it's pointing to is immutable or an instance of a final class.
like Final Map doesn't make sence and doesn't do any thing.
Well, to be fair it does do something, just not the something you want. It prevents this:
And What about the Enumeration and Iterator() ;
As enumeration doesn't allow the modification to Collection
while Iterator() allows Modification.
And that is applied to only COllection framework while Map is not a collection.
What about them? Not sure I understand your question.