Quote:
Originally Posted by Nirnaeth
It might be useful to talk about the reason for this.
Let's say I have two Strings:
String a = "blah";
String b = "blah";
When I instantiate these Strings, Java allocates two different memory locations for them. And 'a' points to the first one that has the "blah" data in it, and 'b" points to another location with the "blah" data in it.
That's why a==b returns false, because 'a' and 'b' are pointing to two different objects, even if they have the same value.
The '==' operator in this case checks to see if they are the same object, not if the have 'equal' values.
|
That's barbaric. At least C++ allows overloading operators.
All my fears of Java are coming true.
Tim