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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:31:09+00:00 2026-06-08T19:31:09+00:00

This problem is driving me nuts! I have declared a static string in a

  • 0

This problem is driving me nuts! I have declared a static string in a constants class as follows:

public static final String REGISTRATION_USERNAME_TAKEN = "Username is already in use. Please choose a different name.";

After a call to a restful web service to register a user, the response (during debugging) is caught and compared to the constant. The response also appears in double double quotes (not sure why) and the result.equals() fails, even though both the result and the constant look exactly the same. Below is a screen capture during debugging in Eclipse which shows the double double quotes. The character count of 61 includes one set of double quotes.

Has anyone seen this before in Eclipse?
Also, why does .equals() fail when both strings have the same values (by that I mean both strings contain the same characters in the same sequence)?

enter image description here

  • 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-08T19:31:11+00:00Added an answer on June 8, 2026 at 7:31 pm

    Regarding the .equals() method failing when comparing a String to an enum constant, actually that’s the default behaviour in case you didn’t override the toString() method in the enum class.

    eg :

    public MyEnum
    {
      LIL, LOL
    }
    
    //try inside main method
    String result = "LOL";
    
    if(result.equals(MyEnum.LOL))
    System.out.println("true");
    else
    System.out.println("false"); //will print false
    

    so if you want to compare a String to the exact String value that an enumeration may have, you can either add a private field to the enumeration that would hold their corresponding String value that you would define inside a constructor and return by overriding toString() inside the enumeration, or you can force the use of toString() simply by doing this :

    if(result.equals((MyEnum.LOL).toString())
    //same code as before would print true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been driving me nuts for a week now. I have a class
This problem is driving me nuts. I have a prototype UITableViewCell in my storyboard.
I have this problem and it's drivin' me nuts! So I am developing my
I've been having this problem for a while and it's driving me nuts. I'm
This has been driving me nuts all day. I've seen this problem crop up
This thing is driving me nuts. I have a UserControl that is called WebUserControl.
This has been driving me nuts all day. I have a weird bug that
I have a simple yet hard problem here that is driving me nuts ...
I'm sure this is simple but it's driving me nuts. I have a ListBox
This is driving me nuts, I can't see the problem. Using jQuery (I'm stuck

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.