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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:52:01+00:00 2026-05-26T20:52:01+00:00

In addition to implementing a Bag & List for an assignment, the next step

  • 0

In addition to implementing a Bag & List for an assignment, the next step is to create an ordered version. A requirement is to specify the parametric interface OrderedCollection with the correct type parameters and constraints. My problem is with implementing it.

An interface Collection <E> exists and is defined as

public interface Collection<E> extends Iterable<E>{
  public void add(E e);
  public void remove(E e);
  public boolean contains(Object e);
  public void clear();
  public int size();
  public boolean isEmpty();
  public Object[] toArray();
}

It is implemented by the classes

public class UnorderedList<E> implements Collection<E>
public class UnorderedBag<E> extends UnorderedList<E> implements Collection<E>

I have the structures working, and am now trying to implement the sorted version. To do this and satisfy part of the requirements, I created OrderedCollection as

public interface OrderedCollection <E extends Comparable<E>> {
  public int compareTo(E e);
}

because it is extending the methods already defined in Collection, and the only new functionality required is a compareTo() method.

However, when I try to implement OrderedList by the declaration

public class OrderedList<E> extends UnorderedList<E> implements OrderedCollection<E>

I get an error stating that

Bound mismatch: The type E is not a valid substitute for the bounded parameter <E
extends Comparable<E>> of the type OrderedCollection<E>

As I understand the error message, I need to specify a parameter type that is a valid substitute for the one given in the interface declaration. However, I’ve tried

OrderedCollection<E extends Comparable<E>>

as the implements declarer, but then I get a warning that a syntax error exists on extends.

How do I satisfy the requirements here?

  • 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-26T20:52:02+00:00Added an answer on May 26, 2026 at 8:52 pm

    In your declaration of the OrderedList class, the generic type of OrderedList needs to match the restriction that OrderedCollection expects.

    public class OrderedList<E extends Comparable<E>> 
                 extends UnorderedList<E> 
                 implements OrderedCollection<E>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm tasked with implementing a survey addition to an existing website. We have been
I'm implementing my own version of sscanf() in a different language (not C or
In addition, are there any performance advantages to static methods over instance methods? I
In addition to informing the user, we want to collect information for our debugging
In addition to being a 30 year pattern, MVC was never meant for current
In addition to this question: iPhone network performance , I would like to know
In addition to the datastore for your specific site, can you also share one
As an addition to my previous post on Creating a web server in pure
this is a small addition to the previous script, and this time I would
I am doing .net programming in addition to c and c++ development and want

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.