🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16413

Re: Enumeration

#16413
From: Steve Schafer (TeamB)
Date: Mon, 01 Mar 1999 00:00
26 lines
1163 bytes
On Sun, 28 Feb 1999 20:31:15 -0800, Shahid Juma <shahidj@interlog.com>
wrote:

>How does Enumeration work?  How do I get every item and see it and print
>it?

Given:

 Enumeration enum;

Do this:

 while (enum.hasMoreElements()) {
   Object obj = enum.nextElement();
   // do something with obj here
   }

Since enumerations generally contain things other than just plain
Objects, you will typically need to use a cast. For example, let's
assume that your enumeration contains Frame objects; then the first
line inside the WHILE loop would look like this:

   Frame f = (Frame) enum.nextElement();

-Steve
 
Technical Details
Message-ID: <373825de.431592350@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36DA1813.495BADDA@interlog.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,bf198c0d006d68dd
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Enumeration
Date: 1999/03/01
Message-ID: <373825de.431592350@90.0.0.40>
X-Deja-AN: 449765895
Content-Transfer-Encoding: 7bit
References: <36DA1813.495BADDA@interlog.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language