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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:25:50+00:00 2026-05-27T12:25:50+00:00

I am trying to compare a double value to another double value inside of

  • 0

I am trying to compare a double value to another double value inside of a TreeMap object. I am getting the following error at the line where I am comparing myPowerAvg to myMap.get(myMap.get(2)). I’m not sure why I’m getting this error as I’m comparing two doubles (btw, this method is executed within a thread).

12-10 22:12:30.524: ERROR/AndroidRuntime(1059): FATAL EXCEPTION: Thread-23
12-10 22:12:30.524: ERROR/AndroidRuntime(1059): java.lang.ClassCastException: java.lang.String
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at java.lang.Integer.compareTo(Integer.java:36)
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at java.util.TreeMap.cmp(TreeMap.java:1317)
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at java.util.TreeMap.get(TreeMap.java:1282)
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at com.community.HomeActivity.setTopUsers(HomeActivity.java:159)
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at com.community.HomeActivity.access$0(HomeActivity.java:136)
12-10 22:12:30.524: ERROR/AndroidRuntime(1059):     at com.community.HomeActivity$4.run(HomeActivity.java:127)

code:

  if(myPowerAvg < myMap.get(myMap.firstKey())){
        TextView view = (TextView)findViewById(R.id.firstPlace);     
    }else{
        TextView view = (TextView)findViewById(R.id.firstPlace);
        view.setText("First Place: \n" + myMap.firstKey() + " " + 
            " at " + myMap.get(myMap.firstKey()) );
    }

    if(myPowerAvg < myMap.get(myMap.get(2)) &&  myPowerAvg > myMap.get(myMap.firstKey())){
        TextView view = (TextView)findViewById(R.id.secondPlace);
        view.setText("Second Place: \n" + AppStatus.mUserName + " " + 
             " at " + myPowerAvg;
    }else{
        TextView view = (TextView)findViewById(R.id.secondPlace);
        view.setText("Second Place: \n" + myMap.get(2) + " " + " at " + 
             myMap.get(myMap.get(2)));
    }
    if(myPowerAvg < myMap.get(myMap.get(2)) &&  myPowerAvg > myMap.get(myMap.firstKey())){ 
        TextView view = (TextView)findViewById(R.id.secondPlace);
        view.setText("Second Place: \n" + AppStatus.mUserName + " " + " at " 
             + myPowerAvg);
     }else{
        TextView view = (TextView)findViewById(R.id.secondPlace);
        view.setText("Second Place: \n" + myMap.get(2) + " " + " at " + 
            myMap.get(myMap.get(2)));
     }
  • 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-27T12:25:51+00:00Added an answer on May 27, 2026 at 12:25 pm

    You say myMap is a TreeMap<String, Double> – but you’re calling myMap.get(2). The param to get should be a string.

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

Sidebar

Related Questions

I am trying to compare the value of 2 instances of x inside an
I was getting the following error message while trying to debug my code: Not
I am trying to compare an array of doubles to a scalar double for
I'm trying to compare a stored variable (user inputs variable value) to a predefined
I'm trying to compare two DataRow s in a loop. However, the following if
I am trying to compare a string to a string value. Seems rather simple,
When trying to compare to php timestamps I seem to be getting an off
I've got a double that prints as 0.000000 and I'm trying to compare it
I am trying to compare the length of a dictionary inside a django template
I am trying to compare a value submitted as a POST to an internal

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.