Originally posted by: juiio
Usually with compareTo
In Java, you use Object.equals() rather than the == operator for reference types. So the only question is if you need to override it (and also if you override Object.hashCode() as well).Originally posted by: notfred
What a peice of crap. How the hell does Java deterine if two objects are equivelent or not?
Originally posted by: manly
In Java, you use Object.equals() rather than the == operator for reference types. So the only question is if you need to override it (and also if you override Object.hashCode() as well).Originally posted by: notfred
What a peice of crap. How the hell does Java deterine if two objects are equivelent or not?
For most of us, not being able to overload operators is not a big deal. The argument goes that operator overloading was more misused than useful.
As far as Sun is concerned, operator overloading is still not an important language feature. Other currently missing features have been deemed important enough for Java 1.5 (Tiger) though.
Originally posted by: Descartes
Originally posted by: manly
In Java, you use Object.equals() rather than the == operator for reference types. So the only question is if you need to override it (and also if you override Object.hashCode() as well).Originally posted by: notfred
What a peice of crap. How the hell does Java deterine if two objects are equivelent or not?
For most of us, not being able to overload operators is not a big deal. The argument goes that operator overloading was more misused than useful.
As far as Sun is concerned, operator overloading is still not an important language feature. Other currently missing features have been deemed important enough for Java 1.5 (Tiger) though.
Although I appreciate that C# and C++ have op overloading, I agree with you. The use of op overloads in C++ always made things difficult to debug when a simple comparison operation threw an exception. I've always been of the opinion that being explicit is better than the taste of syntactic sugar, and abstracting yourself from such details is detrimental; they leak.
.NET does paint a prettier picture, however. C# supports op overloading, but VB.NET and friends do not. VB.NET can still call the emitted op overload methods: op_Addition for +, op_Subtraction for -, op_Equality for ==, etc. This is pretty absurd as it negates the syntactic sugar afforded by op overloading in the first place. Fortunately there are guidelines in place that help mitigate this a bit. In order to pass tests like FxCop for class libraries you have to provide a corresponding public method in place of the op overload: Add for +, Subtract for -, Equals for ==, etc..
Why do I always post a longer response than I anticipated?
Originally posted by: BingBongWongFooey
Originally posted by: Descartes
Originally posted by: manly
In Java, you use Object.equals() rather than the == operator for reference types. So the only question is if you need to override it (and also if you override Object.hashCode() as well).Originally posted by: notfred
What a peice of crap. How the hell does Java deterine if two objects are equivelent or not?
For most of us, not being able to overload operators is not a big deal. The argument goes that operator overloading was more misused than useful.
As far as Sun is concerned, operator overloading is still not an important language feature. Other currently missing features have been deemed important enough for Java 1.5 (Tiger) though.
Although I appreciate that C# and C++ have op overloading, I agree with you. The use of op overloads in C++ always made things difficult to debug when a simple comparison operation threw an exception. I've always been of the opinion that being explicit is better than the taste of syntactic sugar, and abstracting yourself from such details is detrimental; they leak.
.NET does paint a prettier picture, however. C# supports op overloading, but VB.NET and friends do not. VB.NET can still call the emitted op overload methods: op_Addition for +, op_Subtraction for -, op_Equality for ==, etc. This is pretty absurd as it negates the syntactic sugar afforded by op overloading in the first place. Fortunately there are guidelines in place that help mitigate this a bit. In order to pass tests like FxCop for class libraries you have to provide a corresponding public method in place of the op overload: Add for +, Subtract for -, Equals for ==, etc..
Why do I always post a longer response than I anticipated?
It's all that MS in your blood, things you make bloat up easily(seriously, joking, joking
)
