xxxxxxxxxx
import java.util.Scanner;
class Employee {
private String name;
private int age;
Employee(String name, int age){
this.name = name;
this.age = age;
}
}
public class EqualsExample {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter your name ");
String name = sc.next();
System.out.println("Enter your age ");
int age = sc.nextInt();
Employee emp1 = new Employee(name, age);
Employee emp2 = new Employee(name, age);
//Comparing the two objects
boolean bool = emp1.equals(emp2);
System.out.println(bool);
}
}
//Answer of equals method is false coz the address is not same//