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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:51:01+00:00 2026-06-07T07:51:01+00:00

Here is my code: double getRevenue(KeywordGroupKey key) { Double r = revenueMap.get(key); System.out.println(key +

  • 0

Here is my code:

double getRevenue(KeywordGroupKey key) {
    Double r = revenueMap.get(key);
    System.out.println(key + "\t" + key.hashCode());
    for (KeywordGroupKey other : revenueMap.keySet()) {
        System.out.println(other.toString() + "\t" + other.hashCode());
        if(other.equals(key))
            System.out.println("equals here...");
    }
    if(r == null)
        r = 0.0;
    return r;
}

and here is the output:

优惠打折,优惠券|"优惠券"  955095524
brand+点评团购|大众点评 726983298
brand-品牌词相关|团购网站大全  -713384514
brand-品牌词|点评网   2029153675
brand+点评团购|大众点评网    261410621
优惠打折,优惠券|"优惠券"  955095524
equals here...

So it is so strange that the value returned by the method is null, why dose this happen? Since there is a key in the revenueMap has the same hash code and equals with argument key.
Below is the current state of the revenueMap and key:

{brand+点评团购|大众点评=28.0, brand-品牌词相关|团购网站大全=49.9, brand-品牌词|点评网=21.0, brand+点评团购|大众点评网=167.0, 优惠打折,优惠券|"优惠券"=9.9}
优惠打折,优惠券|"优惠券"
  • 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-07T07:51:03+00:00Added an answer on June 7, 2026 at 7:51 am

    My guess is that KeywordGroupKey is mutable and the key in question was modified after it was used as the key of the hash map.

    If that’s the case, then the key is in the wrong “bucket” in the HashMap and the get() method (or containsKey() method) will never find it (but iterating over the keys and/or entries will find it!).

    For example, assuming there’s a property foo in your class and that property is relevant to your hashCode() and equals() methods. The following code would “break” the HashMap:

    KeywordGroupKey key = ...
    revenueMap.put(key, someValue);
    key.setFoo("differentValue");
    Double result = revenueMap.get(key); // will return nothing!
    Double result = revenueMap.get(originalValueOfKey); // will *also* return nothing!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code I have written for Rectangle class. class Rectangle (l: Double,
Here's the c# code that I have: private double get806Fees (Loan loan) { Loan.Fee.Items
Here is my code: double round( char* strNumber, int decPlace); int main() { int
I found the below code here: How to use double buffering inside a thread
Here is my code double hour_payload_add(int entries , double array[]) { int index=0 ,k=0;
Here's what I have: Standard Deviation Mean See code double[] series = { 150,
Here's the code: double angle( double *vec1 , double *vec2 ){ return acos( (
Here is some pseudo c++ code double var = 5.5; cout << var <<
I want to make a sin func. so here's my code: inline double _cdecl
Here is the code double enter_number() { double number; while(1) { cin>>number; if(cin.fail()) {

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.