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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:54:06+00:00 2026-05-31T02:54:06+00:00

The interface NavigableSet<E> extends interface SortedSet<E> which declares the method SortedSet<E> subSet(E fromElement, E

  • 0

The interface NavigableSet<E> extends interface SortedSet<E> which declares the method
SortedSet<E> subSet(E fromElement, E toElement) .
However, when I look at NavigableSet’s API, I see that it has declared the same method (with exactly the same signature). I also see that it says it inherits some methods (first, last, comparable) from SortedSet.

Since by definition, interfaces only contain method signatures, why would any child interface redeclare the same method that the parent interface has already declared (and there’s no difference in semantics, in the API javadoc)?

Edit: Came across a relevant and nice discussion here –
In Java when one interface extends another, why would one redeclare a method in a subinterface?

  • 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-31T02:54:07+00:00Added an answer on May 31, 2026 at 2:54 am

    Doing so is certainly allowed in Java.

    Here is the source code:

    /**
     * {@inheritDoc}
     *
     * Equivalent to {@code subSet(fromElement, true, toElement, false)}.
     */
    public SortedSet<E> subSet(E fromElement, E toElement)
    

    Perhaps the author of the class found it worthwhile to repeat the definition because there is a second definition of subSet that returns a NavigableSet, so having both show up side-by-side in the Javadoc listing was nicer than having one in the main method listing and one in the “inherited” section.

    There was surely no good reason to do this for first and last, so this was not done.

    Here is the rationale from the Javadocs for adding the second versions of subSet, headSet, and tailSet:

    Methods subSet(E, E), headSet(E), and tailSet(E) are specified to return SortedSet to allow existing implementations of SortedSet to be compatibly retrofitted to implement NavigableSet, but extensions and implementations of this interface are encouraged to override these methods to return NavigableSet.

    You might wish to try your own experiment, designing a couple of interfaces, one inheriting from another, with the subinterface adding a new version of an inherited method, to see if the respecification was necessary. 🙂

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

Sidebar

Related Questions

The Interface Segregation Principle (ISP) says that many client specific interfaces are better than
In interface builder there is a control in the struts and springs inspector that
Interface methods in C# can be implemented explicitly, so that their implementation is invoked
Implementing Interface just provide the skeleton of the method. If we know the exact
The interface for service layer is : EMS.java: public interface EMS extends UserDetailsService {
@interface MyClass : NSObject { MyObject *objecto; } I have an object that I
interface Receiver { public <T extends HasId> void doSomethingWithList(List<T> list); } also, class SubClass
Which Interface in android is same as Persistable interface in Blackberry
public interface IPowerList<T> extends Iterable< T > { public int bitFlag(List<T> subseq); } public
Which interface tool would you recommend I use for creating user interfaces for GtkSharp

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.