This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Identify class implementing an Interface

 
Varshini Priya
Ranch Hand
Posts: 95
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a Query regarding the classes that implement an interface. Is there any easy method to identify the classes that are implementing an interface? I use ecllipse as the editor. Is there any shortcut keys available to get this information.

Thanks in Advance
 
Campbell Ritchie
Sheriff
Pie
Posts: 50266
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that any use to you?

[edit]Add 3rd print statement[/edit]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15494
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean that you just want to see in the IDE which classes implement an interface?

Put the cursor on the name of the interface and press F4 (Open Type Hierarchy). That will open a window that shows a tree with all classes that Eclipse can find that implement the interface.
 
Varshini Priya
Ranch Hand
Posts: 95
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell for the below.

I donot have the option to print. Using Editors like ecllipse, is there any short cut available to check the same.

Thanks in Advance
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Eclipse, you can select the interface name, right-click and select Open Type Hierarchy. That will show you, in the current project, the classes that implement the interface.

As a general solution, however, that does not always work because often the implementation class used at runtime is in some other component/project. The thing that has worked best for me is to use the debugger to determine the class of the object, or to print the object.getClass() value.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic