Wait, you mean you have to do it this way:
public boolean equals(Object obj)
{
if (obj instanceof Person)
{
if (getName().equals((Person) obj.getName()))
return true;
}
Type: Posts; User: javapenguin
Wait, you mean you have to do it this way:
public boolean equals(Object obj)
{
if (obj instanceof Person)
{
if (getName().equals((Person) obj.getName()))
return true;
}
It appears the OP is using the equals method of the String class.
This should work.
public boolean equals(String name2)
{
if (getName().equals(name2))
return true;