package study.hard.javalib.nativelib;

public class EqualsTest {

	public static void main(String[] args) {
		EqualsTest tester = new EqualsTest();

		tester.testEqualToOperator();

		tester.testEqualsNotOverrided();

		tester.testEqualsOverrided();
	}

	public void testEqualToOperator() {
		Object a = new Object();
		Object b = new Object();
		System.out.println(a == b); // false
	}

	private void testEqualsNotOverrided() {
		Object a = new Object();
		Object b = new Object();
		System.out.println(a.equals(b)); // false
	}

	private void testEqualsOverrided() {
		OverridedObject a = new OverridedObject();
		a.setAge(30);
		a.setName("tester");
		OverridedObject b = new OverridedObject();
		b.setAge(30);
		b.setName("tester");
		System.out.println(a.equals(b)); // true
	}

	public class OverridedObject {

		private int age;
		private String name;

		public int getAge() {
			return age;
		}

		public void setAge(int age) {
			this.age = age;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == this) {
				return true;
			}
			if (obj == null || obj.getClass() != this.getClass()) {
				return false;
			}

			OverridedObject overrided = (OverridedObject)obj;
			return age == overrided.age
				&& (name == overrided.name || (name != null && name.equals(overrided.getName())));
		}
	}

}

@@ -170,16 +170,51 @@
 Operator
+1();%0A%0A%09%09tester.testEqualToOperator2
 ();%0A%0A%09%09t
@@ -314,16 +314,140 @@
 Operator
+1() %7B%0A%09%09Object a = new Object();%0A%09%09Object b = a;%0A%09%09System.out.println(a == b); // true%0A%09%7D%0A%0A%09public void testEqualToOperator2
 () %7B%0A%09%09O
@@ -1318,16 +1318,17 @@
 e;%0A%09%09%09%7D%0A
+%0A
 %09%09%09if (o

Update test case to use equal to operator.