you can perform == and != on objects (not sure about the > or < tho... ) but it will be perform on the object reference and test whether or not both objects are referring to the same object.Quote:
Originally posted by MethadoneBoy
Operators like ==, >=, <=, != can't be performed on an object.
yadda yadda yadda
How can you perform >, < or >= operations on an object :confused:
with the following code:
(a != b) = trueCode:...
Integer a = new Integer (12);
Integer b = new Integer (12);
Integer c = a;
...
(a == c) = true
(b != c) = true
this is because while a and b have the same value they are not the same object b/c they are seperate instances, where as c points/refers to the same object as a
if you want to perform operations to test whether the objects are equal but not neccessarily the same then get the objects to return some values from methods and compare those values
i hope i answered something :)
