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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:21:03+00:00 2026-05-28T02:21:03+00:00

What is wrong in this code if(getResponseDataMap().containsKey(A){ a.setText(getResponseDataMap().get(A).toString); } Converted like this . getResponseDataMap().containsKey(A)?a.setText(getResponseDataMap().get(A).toString()):

  • 0

What is wrong in this code
if(getResponseDataMap().containsKey("A"){
a.setText(getResponseDataMap().get("A").toString);
}

Converted like this .

getResponseDataMap().containsKey("A")?a.setText(getResponseDataMap().get("A").toString()):""

where getLocalRequestDataMap is a HashMap . And setText is function of android

It give compile time error
Multiple markers at this line
– Type mismatch: cannot convert from String to
boolean
– Syntax error, insert “)” to complete Expression
– Syntax error on token “)”, delete this token

  • 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-28T02:21:03+00:00Added an answer on May 28, 2026 at 2:21 am

    Just on its own, the problem is that you’ve given an expression which isn’t a statement.

    With an assignment, however, it’s fine:

    import java.util.*;
    
    public class Test {
        public static void main(String[] args) {
            HashMap<String, String> map = new HashMap<String, String>();
    
            String x = map.containsKey("A") ? "" : "";
        }
    }
    

    I suspect the problem is in some code you haven’t shown. Please give more context – ideally a short but complete program like mine, but which demonstrates the error.

    EDIT: Now that you’ve edited the question, you’ll probably get a different error. The conditional operator isn’t a valid stand-alone statement, and each of the operands needs to be a non-void expression (with some other caveats as well). So instead of this:

    getResponseDataMap().containsKey("A") ?
        a.setText(getResponseDataMap().get("A").toString()):""
    

    I suspect you want:

    a.setText(getResponseDataMap().containsKey("A") ? 
              getResponseDataMap().get("A").toString() : null);
    

    However, I would personally write this as:

    Object response = getResponseDataMap().get("A");
    a.setText(response == null ? "" : response.toString());
    

    On the other hand, if you only want to set the text when the map contains the key, then you should go back to your original if statement, or possibly:

    Object response = getResponseDataMap().get("A");
    if (response != null) {
        a.setText(response.toString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is wrong with this code? var myRutabaga = $(rutabaga); if(myRutabaga.checked){ document.$(likerutabagas) = LIKE;
what is wrong in this code? I'm trying to get this effect: fadeOut(500) and
Whats wrong with this code? Trying to get my text to insert at the
What is wrong with this code? I get an empty array. I am passing
What's wrong with this code? I get: TypeError: older is undefined (10 out of
What is wrong with this code below. I always get FALSE, meaning after compression,
could anyone please tell me what is wrong this this code? I get a
What's wrong with this code? jQuery $(document).ready(function() { $(#routetype).val('quietest'); )}; HTML <select id=routetype name=routetype>
Whats wrong with this code? function test() { (function(){ console.log('1') })() (function(){ console.log('2') })()
Whats wrong with this code under ARC? I get above error: - (Moment *)initMoment:(BOOL)insert

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.