mardi 26 juillet 2016

methods after extending abstract class

I don't know exacly how to describe my problem so I'll make an example:

public abstract class A {

  public abstract void methodToOverride();
  public void methodNotToOverride() { }

}

public class B extends A {

  @Override
  public void methodToOverride() { }
  public void someOtherMethodNotFromClassA() { }

}

now I need to do such thing in my code:

A object = new B();
object.someOtherMethodNotFromClassA();

but I get "Cannot resolve method error". Defining such method in the abstract class is not an option. Any clue?

Aucun commentaire:

Enregistrer un commentaire