home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-05-08 | 977 b | 43 lines |
- class A {
- public static void main(String[] args) {
- Integer myInt = new Integer(5);
- Integer otherInt;
- otherInt = myInt;
- if (otherInt == myInt)
- System.out.println("equal");
- else
- System.out.println("not equal");
- }
- }
-
- class B {
- public static void main(String[] args) {
- Integer myInt = new Integer(5);
- Integer anotherInt = new Integer(5);
- if (anotherInt == myInt)
- System.out.println("equal");
- else
- System.out.println("not equal");
- }
- }
-
- class C {
- public static void main(String[] args) {
- MyClass mc1 = new MyClass(1);
- if (mc1.operatorEquals(mc1))
- System.out.println("equal");
- else
- System.out.println("not equal");
- }
- }
-
- class MyClass extends Object {
- int value;
- MyClass(int value) {
- this.value = value;
- }
- boolean operatorEquals(MyClass test) {
- return (this == test);
- }
- }
-