Bertie
Bertie

Reputation: 17697

Eclipse: Finding superclass or interface for an overriden method

I have a class that extends a supertype, and also implementing several interfaces.

And within that class, i also have an overriden method.

Problem is how do i quickly find out the origin of this method in one of the supertype or interfaces used without having to traverse the types one by one ?

Just like this example:

class HelloWorld 
    extends ParentType 
    implements InterfaceA, InterfaceB, interfaceC {

  // yes it's a overriden method, but is it from ParentType
  // or InterfaceA, or InterfaceB, or InterfaceC ?
  @Override
  public void hello() {
    // do sth here
  }

  ...
}

Furthemore, either the parent type or the interfaces could be extending other types, which might have the overriden method.

Upvotes: 1

Views: 147

Answers (2)

user6046597
user6046597

Reputation:

You can use keyword super.class It will help you find out from which class it is coming from.

Upvotes: 1

Eran
Eran

Reputation: 394016

Eclipse displays for each overridden method a green arrow-like triangle on the left of the method's first line. When you click on that triangle, it takes you to the class/interface containing the method that your method is overriding/implementing.

enter image description here

Upvotes: 1

Related Questions