Activity Sequence: Java

This is as an illustrative example for how Expression Tutor activities could be used in a Java course. The content on this page may not be understandable for someone without significant prior knowledge.

In Java, instance methods are invoked in code like this: object.method().

Method Invocation

Assume a variable pac of type Pacman, where Pacman is a class that has a method boolean move(int x, int y). Here is how we could invoke that method to get our pac to move to position 12, 6.

Below is a tree representation of the above expression. You can see four nodes. The node pac represents the variable. It has type Pacman. The nodes 12 and 6 represent the two literals. They have type int. The root node represents the method invocation. It has three children: first, the object on which to invoke the method (pac), and then the two arguments to the method. Given that the method has return type boolean, the root node has type boolean.