Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map Vs Dictionary

 
sumit anand kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know Dictionary has been unoffficially deprecated. But comparing Map & DIctionary, I can't find any differences.
Is there a basic design difference i missed?
Also since now its unofficially deprecated, doesn't it means we should not be encouraged to use HashTable and use ConcurrentHashMap instead.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumit anand kumar wrote:I know Dictionary has been unoffficially deprecated. But comparing Map & DIctionary, I can't find any differences.
Is there a basic design difference i missed?


Dictionary is an abstract class. Map is an interface.

Dictionary uses classes and methods that predate the Collections Framework. Map uses classes and methods that were created to be part of the Collections Framework from the ground up.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as unofficially deprecated. But many people regard Dictionary as legacy code, and the API describes it as obsolete.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, Map is a new term of Dictionary ADT.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:I think, Map is a new term of Dictionary ADT.
Afraid it isn’t. The two are similar, however.
 
Walter Gabrielsen Iii
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read somewhere that because Dictionary is an abstract class instead of an interface like Map, and because Java classes can only have 1 superclass, all of Dictionary's subclasses are forever trapped under the Dictionary inheritance tree and can't be moved to fill other rolls in other inheritance trees.

Dictionary is more like java.util.AbstractMap than the Map interface.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Walter Gabrielsen Iii wrote: . . . because Java classes can only have 1 superclass, all of Dictionary's subclasses are forever trapped . . .
That is correct. Also, by implementing an interface, you can make a class appear to extend two things (or more).

Both of those are advantages to implementing rather than extending something.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic