# Viewing the type hierarchy

In this section, you will learn about using the Hierarchy view by viewing classes and members in a variety of different ways.

1. In the Package Explorer view, find junit.framework/TestCase.java. From its context menu, select Open Type Hierarchy. You can also open type hierarchy view:
   - from the menu bar by selecting Navigate > Open Type Hierarchy.
   - from the keyboard by pressing `F4` after selecting TestCase.java.

2. The buttons in the view tool bar control which part of the hierarchy is shown. Click the Show the Type Hierarchy button to see the class hierarchy, including the base classes and subclasses. The small arrow on the left side of the type icon of TestCase indicates that the hierarchy was opened on this type.

3. Click the Show the Supertype Hierarchy button to see a hierarchy showing the type's parent elements including implemented interfaces. This view shows the results of going up the type hierarchy.

   In this "reversed hierarchy" view, you can see that TestCase implements the Test interface.
4. Click the Show the Subtype Hierarchy button in the view toolbar.

5. Click the Lock View and Show Members in Hierarchy button in the toolbar of the member pane, then select the runTest() method in the member pane. The view will now show all the types implementing runTest().

6. In the Hierarchy view, click the Show the Supertype Hierarchy button. Then on the member pane, select `countTestCases()` to display the places where this method is declared.

7. In the Hierarchy view select the Test element and select Focus On 'Test' from its context menu. Test is presented in the Hierarchy view.
8. Activate the Package Explorer view and select the package junit.framework. Use Open Type Hierarchy from its context menu. A hierarchy is opened containing all classes of the package. For completion of the tree, the hierarchy also shows some classes from other packages. These types are shown by a type icon with a white fill.

9. Use Previous Type Hierarchies to go back to a previously opened element. Click on the arrow next to the button to see a list of elements or click on the button to edit the history list.

If you are working in the editor and only want to do a quick lookup for a hierarchy you can use the Quick Type Hierarchy:

1. Open junit.framework.TestCase.java file in the Java editor if you do not already have it open.
2. Select the type name in the Java editor
3. Press `Ctrl+T` or invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
4. Pressing `Ctrl+T` while the type hierarchy view is shown will toggle between supertype hierarchy and subtype hierarchy.

To see where a virtual method call can resolve to:

1. In the body of runBare() select the invocation of setUp()
2. Press `Ctrl+T` or invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
3. You can see that setIup() is implemented in 3 more classes. Object and Assert are only shown with a white filled images as are only required to complete the hierarchy but do not implement setUp()
4. Select a type to navigate to its implementation of setUp()

Java views

Type Hierarchy view
Java Base preference page