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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:09:38+00:00 2026-06-13T14:09:38+00:00

So I am attempting to create a LinkedHashedDictionary’s Iterator member for a homework assignment,

  • 0

So I am attempting to create a LinkedHashedDictionary’s Iterator member for a homework assignment, however I am having multiple issues regarding its types.

Iterator Interface:

package nhUtilities.containers2;

public interface Iterator<Element> extends Cloneable, java.util.Iterator<Element>
{
  public void reset ();
  public void advance ();
  public boolean done ();
  public Element get ();
  public boolean equals (Object obj);
  public boolean traverses (Object container);
  public Object clone ();
  public void setEqualTo (Iterator<Element> other);
  public boolean hasNext ();
  public Element next ();
  public void remove ();
}

In my code, I have a private class called EntryIterator. It extends an AbstractIterator, but implements the Iterator above.

My current implementation is as follows:

private class EntryIterator<Element> extends AbstractIterator<Element>
    implements Iterator<Element>
    {

        protected Iterator<Key> keyIterator;
        protected Dictionary<Key,Value> dictionary;

        public EntryIterator(Dictionary<Key,Value> dictionary)
        {
            keyIterator = keys.iterator();
            this.dictionary = dictionary;
        }

        public void reset()
        { keyIterator = keys.iterator(); }

        /**
         * @Requrie !this.done()
         */
        public void advance()
        { keyIterator.advance(); }

        public boolean done()
        { return keyIterator.done(); }

        // public Entry<Key,Value> get()
        // Violates initial Interface: Results in compile error.
        // Return type must be "Element"
        public Element get()
        {
            Key key = keyIterator.get();
            Value value = dictionary.get(keyIterator.get());
            return (Element) new Entry<Key,Value>(key, value);
        }

        public boolean traverses(Object container)
        {
            // TODO Iterator traverses
            return false;
        }

        public void setEqualTo(Iterator<Element> other)
        {
            this.keyIterator = ((EntryIterator<Element>) other).keyIterator;
            this.dictionary = ((EntryIterator<Element>) other).dictionary;
        }

    }

I have done multiple varieties of this class regarding its types, but none of them seem to be compatible with my Dictionary. Should I keep the formatting as is above, I get an error on my Dictionary’s iterator() function:

public Iterator<Entry<Key,Value>> iterator()
{
    return new EntryIterator<Entry<Key,Value>>(this);
}

The error states it is “The return type is incompatible for Dictionary.iterator()”

Should I change the type of the EntryIterator class’ type to:

private class EntryIterator<eEntry<Key,Value>> extends AbstractIterator<Element>
implements Iterator<Element>

I simply get an error saying “Syntax error expected on token ‘<‘” as well as another incompatibility error on my Dictionary.Iterator() function.

Can someone point me in the right direction as to how I can link up all of these different types to get them to return what my contract for Dictionary demands?

I have attempted asking my question during the class, via email to the instructor, as well as one on one merely to be avoided. Any help would be much 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-06-13T14:09:39+00:00Added an answer on June 13, 2026 at 2:09 pm

    So, the problem was actually with my class instantiation… Here for everyone with similar issues:

     private class EntryIterator extends AbstractIterator<Entry<Key,Value>> implements 
    nhUtilities.containers2.Iterator<Entry<Key, Value>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a ListView adapter that has multiple types of views. I'm
Attempting to create an itemgroup for use in a target where the file types
I am attempting to create multiple, serial writing sessions with AVAssetWriter. Once I've completed
I'm attempting to create a Product Engine for Apostrophe. I'm having trouble extending the
I am attempting to create my own hash class for a school assignment, but
While attempting to create a replacement tablespace for USER, I accidentally created a datafile
Im attempting to create a new operator :? on lists, which operates the same
I attempting to create an 800x500 div with four overlapping divs inside the container
I attempting to create custom tabs using this . But when I try to
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv

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.