• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Enumeration or instance methods

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have coded using both implements Enumerations as well as create instance methods that do the same thing and have yet to figure which way is better. I would guess that implementing Enumeration would be better if you had client code that called for such (As it perhaps should or maybe better some other Collections interface). But what are the costs, if any, on the object creation for Enumeration vs. just having instance methods that would do the same?
Furthermore, since Enumeration is now becoming obsolete because of the Collections interface, which interface will now be the norm for doing such a task? Does this mean we will skip implementing a Collections interface and stick with our own? I hope not.
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The interface that replaces Enumeration is the Iterator.
The API doc says that new implementations should consider
using the Iterator over the Enumeration. I think in terms
of writing your own methods to accomplish the same thing as
Enumeration/Iterator, I would strongly suspect the library
methods will be as fast or faster.
 
reply
    Bookmark Topic Watch Topic
  • New Topic