0

Has an interface with some functions. The base class implements the interface. Then in the subclass would like to override the function.

But the @override gives complier error "method does not override method from its superclass"

Question: in sub class, how to override the interface function implemented in base class?

public interface TheCallback {
    void onImageUrlReady(final ImageView view, final ImageRecord imageData);

}

public class ImageFragment extends Fragment implements TheCallback {

    @Override 
    void onImageUrlReady(final ImageView view, final ImageRecord imageData) {
        //base class implementation
    }
}

public class DerivedFragment extends ImageFragment  {
    @Override //<=== got compile error here
    void onImageUrlReady(final ImageView view, final ImageRecord imageData) {
        //sub class override implementation
    }
}
lannyf
  • 9,865
  • 12
  • 70
  • 152

1 Answers1

1

You are probably using Java 1.5. @Override can be used on implemented interface methods from 1.6.

Also see Why is javac failing on @Override annotation

Community
  • 1
  • 1
Nazaret K.
  • 3,409
  • 6
  • 22
  • 31