# 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.

10. From the menu bar, select Window > Preferences. Go to Java and select Open a new Type Hierarchy Perspective. Then click OK.
11. In the Hierarchy view, select the Test element again, and activate Open Type Hierarchy from the Navigate menu bar. The resource containing the selected type is shown in a new perspective (the Hierarchy perspective), and its source is shown in the Java editor. By setting the preference option for viewing type hierarchy perspectives, you can have more than one type hierarchy in your workbench and switch between them as needed.

Java views

Using the Hierarchy view

Type Hierarchy view
Java Base preference page