equals() Method

equals-method.jpg

Example:

class Employee {
	// ...
	@Override
	public boolean equals(Object obj) {
		if(obj == null)
			return false;
			
		if(this == obj)
			return true;
			
		if(! (obj instanceof Employee))
			return false;
			
		Employee other = (Employee) obj;
		if(this.id == other.id)
			return true;
		return false;
	}
}

equals-method.jpg


Garbage Collection

Screenshot (1331).png

Example: