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?
You are right it does surround the value with extra double quotes in the quick preview.
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
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);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With