0

I want to create different classes and they should be all stored in one ArrayList. If i use:

interface ProgramInterface { 
   void someMethods();
}

public abstract class CustomProgram implements ProgramInterface { 
   // stuff
}

Then i can make my own class like

class P_randomBars extends CustomProgram {

What i like about this is that the methods from the interface show up in the javadoc and from CustomProgram in the same page (CustomProgram).

But then i can't store them in one array (or i have to store them as object which i don't want).

Another way is:

public interface CustomProgram {
   void someMethods();
}

public abstract class ProgramBase {
  // stuff
}

And then i create a classes like:

class P_randomBars extends ProgramBase implements CustomProgram{

What i like is that i can store classes i make like that in a ArrayList. Like: ArrayList<CustomProgram> programs = new ArrayList<CustomProgram>();

But in the javadoc the abstract class and the interface are not connected which make's unclear for the user that he has to extend and then implement.

Is there a solution for this?

clankill3r
  • 9,146
  • 20
  • 70
  • 126

0 Answers0