Java Reference
In-Depth Information
I.2.1
Using the Interactions Pane
The Interactions Pane has a prompt, “ > ”. You can type Java expressions and
statements at the prompt. Try it: click in the Interactions pane, type 3 + 4 * 5
and hit the return/enter key. Underneath the expression you should see the result:
23 . Notice that the 23 does not have the prompt before it.
This interactive feature, missing from most IDEs, has revolutionized how
we teach because we can use it to demonstrate during our lectures.
You can type as many expressions as you like, one per line, and after each
one, DrJava will show you the result. You can also declare and initialize variables
in the Interactions Pane:
int i= 4;
Once a variable is declared and initialized, you can use it in expressions:
i * (i + 7)
That is all you need to know to do all the exercises in Chap. 1: just type the var-
ious expression and statements at the prompt.
I.2.2
Using the Definitions Pane
To write a Java class, type this in the Definitions Pane in the upper right:
public class MyPoint {
public int x;
public int y;
}
Figure I.1:
The DrJava GUI
Search WWH ::




Custom Search