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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:36:02+00:00 2026-06-13T19:36:02+00:00

When inspecting Map and SortedMap interfaces, I have noticed many methods that are already

  • 0

When inspecting Map and SortedMap interfaces, I have noticed many methods that are already defined within Map interface are also redefined (not simply let inherited) within the SortedMap.

SortedMap extending Map, why redeclaring some methods like for instance:

Set<K> keySet();
Collection<V> values();

Why this redundancy?

(I use JDK 7)

  • 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-13T19:36:04+00:00Added an answer on June 13, 2026 at 7:36 pm

    I would say that methods are declared in interfaces and methods are defined in classes.

    Map are not guaranteed to be ordered but Sorted Maps are. This means what each method will guarantee is different and needs different documentation.

    The Javadoc for Map.keySet() is highlighting the differences

    Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator’s own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

    Returns:
    a set view of the keys contained in this map

    The Javadoc for SortedMap.keySet() is

    Returns a Set view of the keys contained in this map. The set’s iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator’s own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

    Specified by:
    keySet in interface Map

    Returns:
    a set view of the keys contained in this map, sorted in ascending order

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

Sidebar

Related Questions

Using Guava, I would like to have a map that has the following properties:
I have an std:map defined as follows: std:map<std::string country, std::vector<SomeClass> events>; Holds some events
While inspecting ArrayList API, I noticed something that looks strange. Indeed, here the the
Does std::map move around already inserted values when inserting new data ?
I have a std::map<std::string, myClass*> myMap then I am inserting like follow: if(!myKey.empty()) {
While inspecting delegates in C# and .NET in general, I noticed some interesting facts:
Suppose you have sets of Fluent conventions that apply to specific groups of mappings,
I have constructed a map and loaded it with data. If I iterate over
So I have created a nested template (a map of vectors) using stanford's CS106
When ranging over a map m that has concurrent writers, including ones that could

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.