'Getting all methods in class (not getting method in extend class) [closed]

Hello I want to get all methods in class that extends class2(abstract class), but it also gets method in class2

for example,

public static boolean hasClickedPlayerMethod(Ability ability) {
        for (Method method : ability.getClass().getMethods()) {
            if (!method.getName().equals("activeSkill")) continue;
            System.out.println(method); // returns activeSkill(Player clickedPlayer), activeSkill()
        }
        return false;
    }

// abstract class Ability

public boolean activeSkill() {
        return false;
    }

    public boolean activeSkill(Player clickedPlayer) {
        return false;
    }

// Class BoatMan extends Ability

public BoatMan(Player player) {
        super(...)
    }

    public boolean activeSkill() {
}
...


In this, I want to get only public boolean activeSkill() { but it also gets public boolean activeSkill(Player player) { how can I get only public boolean activeSkill() {? (BoatMan class has only public boolean activeSkill() { but extend class has public boolean activeSkill(Player) {



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source