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

  • Home
  • SEARCH
  • 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 6562719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:44:32+00:00 2026-05-25T13:44:32+00:00

I have a map declared as follows – Map<Date, Long[]> myMap = new TreeMap<Date,

  • 0

I have a map declared as follows –

Map<Date, Long[]> myMap = new TreeMap<Date, Long[]>();

I put some key-value pairs in that map, check the size as follows –

myMap.size(); //returns 29

myMap.values().size(); //returns 31

All the dates (keys) are distinct.

Aren’t those two supposed to return same values?

  • 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-25T13:44:32+00:00Added an answer on May 25, 2026 at 1:44 pm

    Given that the collection returned by TreeMap’s values() method (in JDK 6, at least) has a size as follows:

    public int size() {
        return TreeMap.this.size();
    }
    

    I’d say you have something adding new entries to the map between your two size() calls. To be clear, map.values().size() delegates to map.size(). Therefore there’s no way they can return two different values for the same map with the same contents.

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

Sidebar

Related Questions

I have unsorted map of key value pairs. input = { xa => xavalue,
I have a map declared as follows: map < string , list < string
I have a std::map declared thusly in a legacy MFC application: typedef std::map<long, CNutrientInfo>
I have declared a map like this map<long long, list<SoundInfo *> > m_soundListMap; and
I have a map which I have declared as follows: map<int, bool> index; and
I have a map declared inside a class as follows: class Example { public:
I have my map declared in xaml like this: <my:Map Height=497 CredentialsProvider=key HorizontalAlignment=Left Margin=6,104,0,0
I have a question. First, I declared a map: Map<TwoIntClass, Set<Integer>> m = new
I have the following code. template<class key,class val> bool has_key(key chkey,std::map<key,val> map){ for (std::map<key,val>::iterator
I have declared the following method: private void mockInvokeDBHandler(Map<String, Object>... rows) { List<Map<String, Object>>

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.