Q:

Java overriding equals, array

Here's a code I'm working on, overriding equals. I've not tried compiling, but Netbeans is giving me a warning saying .equals on incompatible types.
public class Customers {
    private String name;

    public Customers(name) {
        this.name = name;
    }

    public boolean equals(String name) {
        return (this.name.equals(name));
    }
} 

Main Class
public class TestCustomers {
    public static void main(String args[]) {
       Customers cus = new Customers[1];
       cus[1] = new Customers("John");
       if(cus[1].equals("John")
           ...
    }
}

This works fine without using Array. But with array, it shows me a warning.
Why does it gives me a warning saying that .equals on incompatible types? Has this got to do with because of Type Erasures in Array?

A:

The complaint may be because
public boolean equals(String name)

doesn't really override the Object.equals-method, since Objects.equals takes an Object as argument, and not a String. (This would probably be evident if you took the habit of explicitly writing @Override in front of the methods you intended to override other methods.)
Saying that a Customer can equal anything but a Customer seems like a really bad idea to me though. I would do something like this:
class Customer {
    private String name;

    public Customer(String name) {
        this.name = String.valueOf(name);
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        return (o instanceof Customer) && ((Customer) o).name.equals(name);
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
} 

And the main class:
public class Main {
    public static void main(String args[]) {
        Customer[] cus = new Customer[1];
        cus[0] = new Customer("John");

        // Compare against name
        if (cus[0].getName().equals("John"))
            System.out.println("Name equals.");

        // Compare against another customer:
        if (cus[0].equals(new Customer("John")))
            System.out.println("Customer equals.");
     }
}

