class Person
{
private int age;
Person(int age)
{
this.age = age;
}
public boolean equals(Object obj);
{
Person p = (Person)obj;
return this.age == obj.age;
}
}
class ObjectDemo
{
public static void main(String[] args)
{
Person p1 = new Person(20);
Person p2 = new Person(20);
System.out.println(p1.equals(p2));
}
|
|