Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange quote characters around static java String (on android?)

I have a String constant defined in a class:

public static final String ABC = "abc";

And I want to compare, if another String is equal:

String test = "abc";
if (test.equals(OtherClass.ABC)) {
    doSomething();
}

This test strangely fails and when I inspect the variables with eclipse, I see that ABC is 2 characters longer than test, and that it looks like this:

ABC: "abc"
test: abc

Where do those quotes come from and how do I get rid of them?

like image 333
sigma Avatar asked Oct 19 '22 20:10

sigma


1 Answers

You are right it does surround the value with extra double quotes in the quick preview.

enter image description here

But when you inspect the value from the Expresions view, then the value is correct. Moreover it fixes the previous behavior of the quick preview

enter image description here

But still the output is the expected. The two values are equal. I believe this is a bug, since this behavior doesn't make sense to me. I might be wrong though. I don't know if this helped, and if it can be considered as an answer, but I wanted to include the screenshots and the comments don't support that.

The code is not from an android project. Just a simple Java project. I'm using eclipse Kepler.

class OtherClass {
    public static final String ABC = "abc";
}

public class MainJsoup {

    public static void main(String[] args) throws Exception {
        String test = "abc";
        if (test.equals(OtherClass.ABC)) {
            System.out.println("They are equal.");
        } else {
            System.out.println("They are unequal.");
            System.out.println("OtherClass.ABC = " + OtherClass.ABC);
        }
    }
}
like image 92
Alkis Kalogeris Avatar answered Nov 04 '22 01:11

Alkis Kalogeris