Of course, you can refer to an abstract class and call it abstract classes, but the object you specify must be an extender of the abstract class.
For example, create a list of different objects, all expanding on one abstract class.
public abstract class ExAbstract { public abstract void abstractmethod() {...} } public class ExampleA extends ExAbstract { @Override... } public class ExampleB extends ExAbstract { @Override... } ... List<ExAbstract> list = new ArrayList<>(); list.add(new ExampleA()); list.add(new ExampleB()); ...
And then you can call it an abstract method.
for (ExAbstract test : list){ test.abstractmethod(); }
(or Java 8)
list.forEach(ExAbstract::abstractmethod);
But if the object does not expand the facts, and he himself was abstract, he would give an error.
EDIT: in your case with the Routine class, you must create a constructor for it, and then create a new object. (I see that you already have a constructor ...) If you want to use the method without creating an object, use static
In Routine.java:
public Routine(ExampleArg a){ this.a = a; }
In your normal call:
Routine r = new Routine(a); r.start();
source share