• Post Reply Bookmark Topic Watch Topic
  • New Topic

Don't Quite Understand Iterator and Enumeration  RSS feed

 
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realize that Enum has been sort of replaced by iterator but I can't quite seem to understand the purpose of it.

I realize it iterates through a list of sorts but why? What is the benefit?

Thanks

 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't say Enum has been replaced by Iterator. Can you give an example or site where you read this?
 
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you're confusing enum with Enumeration?
 
Carey Brown
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public interface Enumeration<E>

An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series.

For example, to print all elements of a Vector<E> v:



Methods are provided to enumerate through the elements of a vector, the keys of a hashtable, and the values in a hashtable. Enumerations are also used to specify the input streams to a SequenceInputStream.

NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration.
 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh okay so its a way to control and print out the elements in a list or set

I didn't know there was a difference between enum and enumeration

 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - so what is the difference?
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't Carey Brown's 7:37:24 AM post answer that? Do you have a specific question?
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also read a tutorial or two.
 
Franklin Marquette
Ranch Hand
Posts: 49
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay that makes perfect sense - thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!