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 822577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:49:12+00:00 2026-05-15T02:49:12+00:00

Goodmorning everybody, I’m having a little problem with a project for school. We are

  • 0

Goodmorning everybody,

I’m having a little problem with a project for school.
We are told to make an Iterator that implements Enumeration over a Hashmap.

So i made this Enumeration:

public Enumeration<Object> getEnumeration() {
        return new Enumeration<Object>() {
            private int itemsDone = 0;
            Collection<Long> keysCollection = getContent().keySet();            
            Long [] keys = keysCollection.toArray(new Long[keysCollection.size()]);


            @Override
            public boolean hasMoreElements() {
                if(itemsDone < getContent().size() +1 ) {
                    return true;
                }else {
                    return false;
                }

            }
            @Override
            public Object nextElement() {               
                return getContent().get(keys[itemsDone++]);
            }
        };
    }

This goes in my Backpack class

public class Backpack extends Item implements Carrier, Enumeration<Object>{

The hashmap is returned by getContent(). The problem now is that eclipse keeps telling me I havent implemented the methods from Enumeration. If I use the quick fix it just adds the hasMoreElements() and nextElement() dummy methods in my class.
Somehow it doesn’t see these methods in the inner class..

Can anyone help me please? Any help is appreciated.

  • 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-15T02:49:12+00:00Added an answer on May 15, 2026 at 2:49 am

    Backpack doesn’t implement it. The anonymous inner class used in getEnumeration does. If you want Backpack itself to implement Enumeration, it needs to have those methods.

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

Sidebar

Related Questions

Goodmorning, I am having a problem figuring out how to sort the following JSON
Goodmorning everybody! I'm not completely new to PHP as in self but still kinda
Good morning everybody! (Yeah I know, that not necessary the morning on your side
Good morning to everybody, :) I have writen a code in C++ that reads
Goodmorning everyone, i fighting against this problem for now 3 hours and i can't
Good morning, I've successfully created a little app that registers itself under a custom
good morning to all. i place a datalist in my project in that i
Goodmorning everybody, I'm doing a query in Access 2010 and I'm getting a strange
Good morning everyone, I tried to sleep over my problem, but I am stuck
Good Morning. I am having trouble with a segment of code that has worked

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.