|
-
Feb 17th, 2002, 12:55 PM
#1
Thread Starter
Hyperactive Member
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
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.
with the following code:
Code:
...
Integer a = new Integer (12);
Integer b = new Integer (12);
Integer c = a;
...
(a != b) = true
(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
"There are only two things that are infinite. The universe and human stupidity... and the universe I'm not sure about." - Einstein
If you are programming in Java use www.NetBeans.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|