Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:07:53+00:00 2026-05-31T20:07:53+00:00

I was reading Enumerations in Java, and every example I have come across uses

  • 0

I was reading Enumerations in Java, and every example I have come across uses the Vector, and then uses Vector.elements() to get the Enumeration to iterate using Enumeration.nextElement().

My question is how to use the Enumeration interface with my classes, for example if I create a simple class that implements Enumeration like so:

public class Tester implements Enumeration{

    private int [] arr = new int[5];
    private int iterator = 0;
    private int count = 0;

    public boolean insert(int item)
    {
        if (count < 5)
        {
            arr[count-1] = item;
            count++;
            return true;
        }
        else
        {
            return false;
        }
    }

    public boolean hasMoreElements() {
        if (iterator >= 4)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    public Object nextElement()
    {
        if (iterator < count)
        {
            iterator++;
            return (Object)arr[iterator -1];
        }
        else
        {
            iterator = 0;
            return nextElement();
        }
    }
}

My questions are:

  1. Whats next? I mean how do I use the Enumeration interface with this
    class? What can I do with it (please also explain the purpose of
    Enumeration and implementing it in a class)?
  2. How to write the Tester.elements() function similar to
    Vector.elements() which is used in the examples over the internet?
  3. What is its equivalent in C#?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:07:54+00:00Added an answer on May 31, 2026 at 8:07 pm

    Enumeration is a Java 1.0 interface that should not be used. It’s been supplanted by java.util.Iterator. I’d recommend that you prefer that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently working on a 3D media engine using C# and I have come across
I am reading a ZIP file using java as below: Enumeration<? extends ZipEntry> zes=zip.entries();
Reading on another forum I've came across the world of CSS Frameworks. The one
Reading through the CKEditor documentation , I see that they have an option to
Reading Real World Haskell, on page 95 the author provides an example: myFoldl f
Reading over some example Objective C code just now. @property (nonatomic, strong) IBOutlet UILabel
I have some general questions regarding the java.util.zip library. What we basically do is
Reading the Oxite source code, I have found that validators save bad property name
Reading this blog post it mentions you can get your DI container to automatically
Reading this question I found this as (note the quotation marks) code to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.