Creating class variations using implements


#1

I would like to create a variation of a class i have written and extends works well but i am limited to using it only once for some strange reason. i have been looking at implements as advised but i cant seem to get my head around it. the reason extends works well is because the new class inherits all of the data and methods as the other class but you can add more. with implements whenever i add a new method it wont compile and the data is not shared between the implementations…if anyone understands what i am trying to say and has a suggestion id be very grateful, thanks.


#2

…ok so i have just created multiple variations of a class using extends. why does it say this in the documentation?

Note that in Java, and therefore also Processing, you cannot extend a class more than once. Instead, see implements .


#3

Yes, that’s backwards. A class cannot (directly) extend more than one other class would be more accurate.


#4

@gonadgranny===
that s simple:

  • with java a class can extend only one another class
  • but a class can implement more than one interface