Extend java.lang.String

No, absolutely not. If you want some “other” kind of string, create another type which might contain a string:

public final class OtherString {
    private final String underlyingString;

    public OtherString(String underlyingString) {
        this.underlyingString = underlyingString;
    }        

    // Override equals however you want here
}

Leave a Comment