S
sunstormrider
Hi guys
OK - I have a pretty basic problem:
If I do
String a = "fred";
String b = "fred";
if (a.equals(b))
{ System.out.println("Equal"); }
else {System.our.println("Not equal"); }
then everything is as I'd expect - i.e. it returns Equal.
However, if I make my Strings StringBuilders, I'm getting a response
I'm not expecting:
StringBuilder a = new StringBuilder("fred");
StringBuilder b = new StringBuilder("fred");
if (a.equals(b))
{ System.out.println("Equal"); }
else {System.our.println("Not equal"); }
I'm getting Not equal. I know StringBuilder inherits from Object but
I can't see how to get around this one with casting. Can anyone help
please it's driving me nuts?
Cheers
Sun
OK - I have a pretty basic problem:
If I do
String a = "fred";
String b = "fred";
if (a.equals(b))
{ System.out.println("Equal"); }
else {System.our.println("Not equal"); }
then everything is as I'd expect - i.e. it returns Equal.
However, if I make my Strings StringBuilders, I'm getting a response
I'm not expecting:
StringBuilder a = new StringBuilder("fred");
StringBuilder b = new StringBuilder("fred");
if (a.equals(b))
{ System.out.println("Equal"); }
else {System.our.println("Not equal"); }
I'm getting Not equal. I know StringBuilder inherits from Object but
I can't see how to get around this one with casting. Can anyone help
please it's driving me nuts?
Cheers
Sun