Nestor,
Following Rob's original e-mail about any element of an Array being directly
accessed via a numeric index as opposed to an Enumeration being traversed
sequentially, yes, an Enumeration is like a unidirectional linked list,
since you can't go backwards.
Enumeration is an interface that is a convenient, least-common-denominator
mechanism for traversing a collection of elements. In Java2, there is a
newer version called Iterator.
HTH
-----Original Message-----
From: Rob van Oostrum [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 14, 2000 12:20 PM
To: [EMAIL PROTECTED]
Subject: Re: Diff. Bet. Enumeration and Array
maybe, maybe not ... at the risk of sounding stupid, I have no clue what a
link list is =)
-----Original Message-----
From: Nestor Florez [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 14, 2000 5:34 PM
To: [EMAIL PROTECTED]
Subject: Re: Diff. Bet. Enumeration and Array
Rob,
So is an enumeration like a link list?
Nestor
-----Original Message-----
From: Rob van Oostrum [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 14, 2000 2:06 AM
To: [EMAIL PROTECTED]
Subject: Re: Diff. Bet. Enumeration and Array
An array is a collection of elements keyed by an index number (or, in the
case of a multi-dimensional array, multiple index numbers, one for each
dimension). Elements can be directly accessed by this index.
An Enumeration is a collection of elements specifically designed to optimize
traversing down a list of elements in optimal fashion. The Enumeration does
not know how big it is. It has a pointer which points to the current
element. The Enumeration is only able to return the next element, or tell
whether or not there is a next element. Therefor, the enumeration can only
be traversed once and is useless after that.
If you want to determine the size of an Enumeration you'll have to do
something like this:
int count=0;
while ( enum.hasMoreElements() )
{
enum.nextElement();
count++;
}
System.out.println( "Size of enum is " + count );
hope this helps
Rob
-----Original Message-----
Hi,
Pl. can anybody tell me the difference between an Enumeration and an
Array.
Is there any function available to get the count of items in the
Enumeration.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets