The Interactions Pane

The Interactions Pane is one of the best and most distinctive features of DrJava. It offers both beginning students and more experienced programmers the ability to quickly try out code without having to write cumbersome main methods.

1. One way to use the Interactions Pane is to input basic Java expressions like 1+1. Those expressions will then be interpreted and evaluated, and the result will be displayed. This example shows how to do basic calculations in the Interactions Pane:

2. Another way to use the Interactions Pane is to instantiate classes and then call their methods--this allows you to quickly and easily verify the behavior of methods. This example shows how to instantiate a class and call one of its methods:

3. In addition, you can define classes and interfaces in the Interactions Pane, and then instantiate these classes and test them. This example shows how to create a class and call one of its methods:

4. It is important to remember that if you are working with classes that are packaged in the Definitions Pane (where the file's text is), it is important to make the same package declaration in the Interactions Pane. Also, you need to import any other packages you wish to use, like you would in a normal .java file. In this example, you can see how the package is used, and also that until the java.util package is imported, Vector cannot be used: