Chapter 5. Covariance
Prev |  | Next

## Chapter 5. Covariance

## Covariance in Java 5

Java 5 (and hence AspectJ 5) allows you to narrow the return type in an overriding method. For example:

    		class A {
    		  public A whoAreYou() {...}
    		}

    		class B extends A {
    		  // override A.whoAreYou *and* narrow the return type.
    		  public B whoAreYou() {...}
    		}

Prev | Home | Next
Inter-type method declarations and method dispatch | Up | Covariant methods and Join Point matching