Overriding members

    Subclasses can override instance methods, getters, and setters.You can use the @override annotation to indicate that you areintentionally overriding a member:

    To narrow the type of a method parameter or instance variable in code that is,you can use the covariant keyword.

    Overridable operators

    You can override the operators shown in the following table.For example, if you define aVector class, you might define a + method to add two vectors.

    Here’s an example of a class that overrides the + and - operators:

    If you override ==, you should also override Object’s hashCode getter.For an example of overriding == and hashCode, see.

    For more information on overriding, in general, seeExtending a class.

    noSuchMethod()

    You can’t invoke an unimplemented method unlessone of the following is true:

    • The receiver has a static type thatdefines the unimplemented method (abstract is OK),and the dynamic type of the receiver has an implemention of noSuchMethod()that’s different from the one in class .