Solved Extending same as implementing

Discussion in 'Plugin Development' started by JellyYods, Feb 1, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    JellyYods

    I have a class that extends JavaPlugin, but I can't extends more than 1 thing. Is extending BukkitRunnable the same as implementing BukkitRunnable. Or is there a way to extend more than 1 thing.

    class main extends JavaPlugin implements BukkitRunnable
     
  2. Offline

    1Rogue

    implementing is for interfaces, extending is for abstract classes. While implementing an interface is also a form of extending, extending isn't the same as implementing.

    Interfaces are more meant to define what methods are available from a class, whereas you should usually use abstract classes to define behavior.
     
    Konato_K likes this.
  3. Offline

    pie_flavor

    In a less confuzzling manner: Extending is like GrannyApple extends Apple which extends Fruit. It's a way of saying that thing A does everything thing B does, but more. For instance, your main class extends JavaPlugin, saying that it is a type of plugin.
    Implementing is for interfaces. An interface is like Lion implements Roarable. The calling class doesn't care about most of the features, all it needs to know is that said class can roar. For instance, when you define a CommandExecutor, the Bukkit internal classes don't care what else your commandsender can do. All they care about is that you have the onCommand method to handle commands.
     
    Xtreme727 likes this.
  4. Offline

    Rocoty

    @1Rogue Of course, extending classes isn't just limited to abstract classes. Just thought I'd clarify that. @JellyYods
     
  5. Offline

    1Rogue

    Well implementing is a form of extending, when an interface "implements" another interface you use "extends" for clarity.
     
  6. Offline

    Rocoty

    @1Rogue Let me clarify further. What I'm saying is that a class doesn't have to be declared abstract in order for another class to extend it. A concrete class can be extended just as well as an abstract class. And this is common practice.

    Edit: I'm also a bit confused about the way you're saying an interface implements another interface. When you use the word 'implements' that implies an implementation is happening. As far as I am aware, interfaces, generally speaking, do not provide any implementation.
     
  7. Offline

    1Rogue

    Ah, then yes.
     
  8. Offline

    pie_flavor

    @Rocoty Interfaces can extend other interfaces. Furthermore, unlike classes, they can extend an unlimited number of other interfaces
     
  9. Offline

    Rocoty

Thread Status:
Not open for further replies.

Share This Page