• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Map Vs Dictionary

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, Map is a new term of Dictionary ADT.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic