Method calls, the details
public class Circle {
static final double
PI = 3.141592653589793;
double r;
/** Change a circle's area
* @param area The desired new area
* @return The circle's new radius */
double setArea(final double area ❶) {
double val ❷ = area / PI ❸;
return ❹ r ❺ = Math.sqrt(val);
}
} |
|||||
|
|
Class scope (static)
|
Application process |
| Instance scope | Object lifetime: new
(...) until being garbage collected.
|
| Method scope | Method invocation until return.
|
- Heap memory
-
-
Allocation of class or array instances:
new String()new float[200] -
De-allocation subject to garbage collection.
-
- Execution stack
-
-
One instance per process thread.
-
Hosting variables (values or references)
-
| Method | Description | Precondition | Access type |
|---|---|---|---|
push(...) |
Add object on top |
- |
Modify |
pop() |
Read + remove topmost object |
Stack not empty |
Modify |
top() |
Read topmost object |
Stack not empty |
Read only |
empty() |
|
- |
Read only |
peek() method
having exactly the «original» stack top()
method's semantic.
|
❶ |
Three call stack frames corresponding to
|
|
❷ |
Local variables corresponding to selected stack frame. TipIn the above example you may select stack frame “circleArea” showing its local variables while leaving your debugger resting at line 3. |
