-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEquality.java
More file actions
29 lines (22 loc) · 581 Bytes
/
Equality.java
File metadata and controls
29 lines (22 loc) · 581 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package classes;
public class Equality {
int a;
int b;
public Equality(int a, int b) {
this.a = a;
this.b = b;
}
public boolean equalTo(Equality passedObject) {
if ((passedObject.a == this.a) && (passedObject.b == this.b))
return true;
else
return false;
}
public static void main(String[] args) {
Equality obj1 = new Equality(100, 100);
Equality obj2 = new Equality(100, 100);
Equality obj3 = new Equality(200, 200);
System.out.println("obj1 == obj2 ? " + obj1.equalTo(obj2));
System.out.println("obj1 == obj3 ? " + obj1.equalTo(obj3));
}
}